-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Pyright fails to find type error if argument uses a high exponent #7877
Comments
It appears this is because |
Yes, this behavior is correct based on the typeshed stub for def __pow__(self, value: int, mod: None = None, /) -> Any: ... |
Closing because pyright is doing the right thing here given the type information it's provided. |
If there was an option to prevent Pyright from accepting an |
Also for what it's worth, |
For future explorers, here are some relevant discussions I found: |
Pyright is not using type inference in this case. It's applying standard type rules (as specified in the Python typing spec) to type information provided by typeshed stubs. Mypy provides special-case logic that overrides the type information provided in the typeshed stubs in this instance. That's something I generally don't do in pyright. I've done it a few times in the past, and I've regretted it every time because it leads to compatibility and maintenance issues. |
That makes sense; thank you for the explanation. It seems like the correct place for me to take this up is with typeshed's policy of avoiding union types for return values. |
Describe the bug
When an expression involving an integer and a high exponent (e.g.
2**31
) is passed into a function expecting a non-integer type, Pyright doesn't catch the error. I've tried this with lower exponents (e.g.2**2
) and Pyright does correctly catch the error.Code or Screenshots
(pyright playground link)
VS Code extension or command-line
Command-line, version 1.1.361, strict mode on.
The text was updated successfully, but these errors were encountered: