Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partially apply doshitan's #1238 part 1 #1239

Merged

Conversation

grahamc
Copy link
Member

@grahamc grahamc commented Mar 2, 2020

Pulls out a few commits which are obviously right, making #1238 a bit smaller and easier to review.

doshitan and others added 3 commits March 2, 2020 11:56
An alternative implementation of NixOS#1238 from GitHub user doshitan which
used Literal[...] as a sort of dependent type:

    +    @overload
    +    def run_command(
    +        self,
    +        command: Command,
    +        flags: List[str] = ...,
    +        timeout: Optional[int] = ...,
    +        logged: bool = ...,
    +        allow_ssh_args: bool = ...,
    +        user: Optional[str] = ...,
    +        *,
    +        capture_stdout: Literal[False],
    +        **kwargs: Any
    +    ) -> int:
    +        ...
    +
    +    @overload
    +    def run_command(
    +        self,
    +        command: Command,
    +        flags: List[str] = ...,
    +        timeout: Optional[int] = ...,
    +        logged: bool = ...,
    +        allow_ssh_args: bool = ...,
    +        user: Optional[str] = ...,
    +        *,
    +        capture_stdout: Literal[True],
    +        **kwargs: Any
    +    ) -> str:
    +        ...
    +
    +    @overload
    +    def run_command(
    +        self,
    +        command: Command,
    +        flags: List[str] = [],
    +        timeout: Optional[int] = None,
    +        logged: bool = True,
    +        allow_ssh_args: bool = False,
    +        user: Optional[str] = None,
    +        **kwargs: Any
    +    ) -> Union[str, int]:
    +        ...

however, I think this option is much simpler and improves the API.
Possibly in the future we will add this more complex type.
@grahamc grahamc merged commit 61dac23 into NixOS:start-with-types Mar 2, 2020
@grahamc grahamc deleted the partially-apply-doshitan-1238-part-1 branch March 2, 2020 17:43
@grahamc grahamc added this to the 2.0 milestone Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants