-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
OSError.errno can be None #12910
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
OSError.errno can be None #12910
Conversation
|
Diff from mypy_primer, showing the effect of this PR on open source code: mkosi (https://github.com/systemd/mkosi)
+ mkosi/sandbox.py:324:22: error: Argument 1 to "_exit" has incompatible type "Optional[int]"; expected "int" [arg-type]
bokeh (https://github.com/bokeh/bokeh)
+ src/bokeh/command/util.py: note: In function "report_server_init_errors":
+ src/bokeh/command/util.py:217:40: error: Invalid index type "int | None" for "Mapping[int, str]"; expected type "int" [index]
pytest (https://github.com/pytest-dev/pytest)
+ src/_pytest/_py/error.py:101: error: Argument 1 to "_geterrnoclass" of "ErrorMaker" has incompatible type "Optional[int]"; expected "int" [arg-type]
cloud-init (https://github.com/canonical/cloud-init)
+ cloudinit/url_helper.py:84: error: Incompatible return value type (got "int | None", expected "int") [return-value]
mypy (https://github.com/python/mypy)
+ mypy/modulefinder.py:780: error: Argument 1 to "strerror" has incompatible type "Optional[int]"; expected "int" [arg-type]
+ mypy/build.py:2147: error: Argument 1 to "strerror" has incompatible type "Optional[int]"; expected "int" [arg-type]
manticore (https://github.com/trailofbits/manticore)
+ manticore/platforms/linux.py:1767: error: Unsupported operand type for unary - ("int | None") [operator]
+ manticore/platforms/linux.py:1780: error: Unsupported operand type for unary - ("int | None") [operator]
+ manticore/platforms/linux.py:1810: error: Unsupported operand type for unary - ("int | None") [operator]
+ manticore/platforms/linux.py:2340: error: Unsupported operand type for unary - ("int | None") [operator]
+ manticore/platforms/linux.py:3512: error: Unsupported operand type for unary - ("int | None") [operator]
+ manticore/platforms/linux.py:3525: error: Unsupported operand type for unary - ("int | None") [operator]
+ manticore/platforms/linux.py:3560: error: Unsupported operand type for unary - ("int | None") [operator]
+ manticore/platforms/linux.py:3578: error: Unsupported operand type for unary - ("int | None") [operator]
+ manticore/platforms/linux.py:3590: error: Unsupported operand type for unary - ("int | None") [operator]
+ manticore/platforms/linux.py:3668: error: Unsupported operand type for unary - ("int | None") [operator]
+ manticore/platforms/linux.py:3681: error: Unsupported operand type for unary - ("int | None") [operator]
|
|
Thanks! This has been discussed before, see #9864. Making a change here is currently deferred, pending some decisions on what the right CPython behavior should be |
|
As was predicted in #9864 (comment), it seems like this change is quite disruptive. This does also seem like exactly the kind of potential bug in your code that type checkers are meant to warn you about, however. And, as was mentioned in #9864 (comment), even if it is decided that this is a bug in CPython and a fix is applied at runtime, the fix might not be backported, and almost certainly won't be backported as far back as typeshed's lowest supported Python version (currently 3.8). So I'm in favour of making a change to the stubs here. |
|
I also agree with merging this. I'd encourage anyone reading this to send PRs to the affected projects in the mypy-primer results to fix the issue. |
Code in cpython seems to always throw TimeoutError with no arguments.