-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
builtins stubtest exceptions #5219
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
Conversation
hatal175
commented
Apr 15, 2021
- I've just left 'class function' - anyone can explain what it is and why it is there?
Diff from mypy_primer, showing the effect of this PR on open source code: pip (https://github.com/pypa/pip.git)
+ src/pip/_internal/operations/install/wheel.py:620: error: Incompatible types in assignment (expression has type "chain[File]", variable has type "map[File]")
+ src/pip/_internal/operations/install/wheel.py:646: error: Incompatible types in assignment (expression has type "filterfalse[File]", variable has type "map[File]")
+ src/pip/_internal/operations/install/wheel.py:650: error: Incompatible types in assignment (expression has type "chain[File]", variable has type "map[File]")
bidict (https://github.com/jab/bidict.git)
+ bidict/_orderedbidict.py:63: error: "object" not callable
|
There's #2999 for builtins.function |
The |
Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Jelle Zijlstra <[email protected]>
Diff from mypy_primer, showing the effect of this PR on open source code: pip (https://github.com/pypa/pip.git)
+ src/pip/_internal/operations/install/wheel.py:620: error: Incompatible types in assignment (expression has type "chain[File]", variable has type "map[File]")
+ src/pip/_internal/operations/install/wheel.py:646: error: Incompatible types in assignment (expression has type "filterfalse[File]", variable has type "map[File]")
+ src/pip/_internal/operations/install/wheel.py:650: error: Incompatible types in assignment (expression has type "chain[File]", variable has type "map[File]")
bidict (https://github.com/jab/bidict.git)
+ bidict/_orderedbidict.py:63: error: "object" not callable
|
1 similar comment
Diff from mypy_primer, showing the effect of this PR on open source code: pip (https://github.com/pypa/pip.git)
+ src/pip/_internal/operations/install/wheel.py:620: error: Incompatible types in assignment (expression has type "chain[File]", variable has type "map[File]")
+ src/pip/_internal/operations/install/wheel.py:646: error: Incompatible types in assignment (expression has type "filterfalse[File]", variable has type "map[File]")
+ src/pip/_internal/operations/install/wheel.py:650: error: Incompatible types in assignment (expression has type "chain[File]", variable has type "map[File]")
bidict (https://github.com/jab/bidict.git)
+ bidict/_orderedbidict.py:63: error: "object" not callable
|
def __len__(self) -> int: ... | ||
def __iter__(self) -> Iterator[int]: ... | ||
def __str__(self) -> str: ... | ||
def __repr__(self) -> str: ... | ||
def __int__(self) -> int: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if these were added on purpose to make bytes fulfill the SupportsInt
and SupportsFloat
protocols. int(b'12')
works at runtime. Probably safer to keep them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- no mypy primer diffs
- the int __new__ function specifically gets bytes (so does float) and treats it as a string: https://github.com/python/cpython/blob/62ec63864822de1dd1933225584e8503ac40c1f9/Objects/longobject.c#L4960
- Other functions that receive SupportsInt fail on bytes - itertools.count(b'1',1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, I will merge
Why were all these overloaded functions changed to classes? This breaks deduction in certain contexts. |
I'm not yet convinced that this PR has anything to do with that. I added this function to your mypy playground link, based on what this PR deletes, and used it instead of
It still gives the same number of errors. |