-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Infer type var tuple contents in more situations #18958
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
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
|
The only bad change in mypy primer is: ... and I'm not quite sure if there's a good way to solve this. We could check whether constraints interfere with each other and only if they do prefer the higher quality ones? That sounds slow, though. (EDIT: I did that, but again I'm not confident it's right) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@ilevkivskyi this is my best guess at a mechanism that would handle |
|
Diff from mypy_primer, showing the effect of this PR on open source code: sockeye (https://github.com/awslabs/sockeye)
+ sockeye/layers.py:530: error: Unused "type: ignore" comment [unused-ignore]
+ sockeye/layers.py:873: error: Unused "type: ignore" comment [unused-ignore]
core (https://github.com/home-assistant/core)
+ homeassistant/util/signal_type.pyi:57: error: Unused "type: ignore" comment [unused-ignore]
+ homeassistant/util/signal_type.pyi:57: error: Argument 2 to "async_dispatcher_send" has incompatible type "SignalType[int]"; expected "SignalType[str]" [arg-type]
+ homeassistant/util/signal_type.pyi:57: note: Error code "arg-type" not covered by "type: ignore" comment
|
Supersedes #17512 as I figured out how to handle this case in a more general manner.
This PR fixes #16522. It adds a mechanism for constraints to be discarded if they are less likely to be correct: for instance, if you pass
f(x: int, y: str = "42")toCallable[[Unpack[Ts]], None]it's not clear whetheryshould be included in an unpackedTypeVarTuple. This PR makes it such thatfunction_using_typevartuple(f, 42)discards constraints based onf.