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

fcntl: various improvements #3680

Merged
merged 4 commits into from
Feb 22, 2020
Merged

fcntl: various improvements #3680

merged 4 commits into from
Feb 22, 2020

Conversation

hauntsaninja
Copy link
Collaborator

  • use overload for fcntl.ioctl
  • use overload for fcntl.fcntl
  • mark positional-only args

@hauntsaninja
Copy link
Collaborator Author

Little less sure about this one...

  • The comment about depending on the type of cmd, not arg seems incorrect (introduced in bf50135). I checked the docs and examples, CPython implementation and CPython tests, but
    I might be missing something.
  • This isn't a module I really know how to use, so my testing was mainly limited to the examples in the documentation.
  • If there's a good way to type buffers and mutable buffers, let me know, and I can remove the other TODO as well.

__request: int,
__arg: bytearray,
__mutate_flag: Literal[True] = ...) -> int: ...
@overload
Copy link
Member

Choose a reason for hiding this comment

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

I think this overload can be omitted (note that bytearray is treated as a subtype of bytes to the typechecker).

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

For the buffer protocol, see python/typing#593.

hauntsaninja added 4 commits February 4, 2020 16:04
The comment about depending on the type of arg seems incorrect
python@bf50135

I checked the docs and examples, CPython implementation and CPython tests, but
I might be missing something
Based off of docs and examples
Follows the approach in python#2610
@JelleZijlstra JelleZijlstra merged commit 1b7eadc into python:master Feb 22, 2020
@hauntsaninja hauntsaninja deleted the fcntl branch February 22, 2020 05:32
Rahix added a commit to Rahix/tbot that referenced this pull request Mar 11, 2020
A recent change in Python's typeshed [1] leads to mypy complaining that
there is no overload for ioctl() with the signature `int, int, bytes`.
By adding an explicit `mutate_flag=False`, another overload is selected
and mypy stays quiet.

[1]: python/typeshed#3680

Signed-off-by: Harald Seiler <[email protected]>
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