Skip to content

Use overlapped signatures of _winapi functions #2723

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

Merged
merged 4 commits into from
Jan 7, 2019

Conversation

emmatyping
Copy link
Member

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few notes regarding the overlapped flag below.

@emmatyping
Copy link
Member Author

@srittau I can provide an overload if overlapped is None but otherwise I'm not sure what you are suggesting? For example for ConnectNamedPipe the correct signature is something like:

@overload
def ConnectNamedPipe(handle: int, overlapped: Literal[True, 1]) -> Overlapped: ...
@overload
def ConnectNamedPipe(handle: int, overlapped: Optional[Literal[False, 0]] = None) -> None: ...
@overload
def ConnectNamedPipe(handle: int, overlapped: Union[bool, int, None] = None) -> Optional[Overlapped]: ...

but we aren't at the point where I can start using Literal types in typeshed, correct?

@srittau
Copy link
Collaborator

srittau commented Jan 6, 2019

Um, good point. I blame too much typeshed lately. Then we should just Any as return value for now (except for the None/not provided case).

@emmatyping
Copy link
Member Author

I realized I was wrong, and None is not a valid argument to overlapped, so I just did an overload of where it is omitted. Hopefully this looks like what you wanted?

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! A good case for literal types.

@srittau srittau merged commit ad304cb into python:master Jan 7, 2019
@emmatyping emmatyping deleted the patch-4 branch January 7, 2019 11:20
@emmatyping
Copy link
Member Author

Indeed! Looking forward to being able to use them :)

yedpodtrzitko pushed a commit to yedpodtrzitko/typeshed that referenced this pull request Jan 23, 2019
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.

2 participants