We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
isinstance
Bug Report
This may be a duplicate but I couldn't find any.
See the title for a short description or the short reproduction attached.
To Reproduce
a: object b: tuple[type[int], ...] if isinstance(a, b): reveal_type(a)
Expected Behavior
main.py:5: note: Revealed type is "builtins.int" Success: no issues found in 1 source file
Actual Behavior
main.py:5: note: Revealed type is "builtins.object" Success: no issues found in 1 source file
This works, however:
a: object b: tuple[type[int]] if isinstance(a, b): reveal_type(a)
Your Environment
https://mypy-play.net/?mypy=latest&python=3.11&gist=050eb94523510217a3bf91e9977539d0
The text was updated successfully, but these errors were encountered:
Yes, looks like a problem that can be easily fixed.
Here's a more real-life example that can illustrate the same problem:
class Base: ... class Impl1(Base): ... class Impl2(Base): ... impls: tuple[type[Base], ...] = (Impl1, Impl2) some: object if isinstance(some, impls): reveal_type(some) # must be `Base`
I have a fix ready :)
Sorry, something went wrong.
tuple[type[X], ...]
Correctly narrow types for tuple[type[X], ...] (#15691)
da1853f
`flatten_types` forgot about the second way we represent `tuple` inside. Closes #15443 --------- Co-authored-by: Ilya Priven <[email protected]>
Successfully merging a pull request may close this issue.
Bug Report
This may be a duplicate but I couldn't find any.
See the title for a short description or the short reproduction attached.
To Reproduce
Expected Behavior
Actual Behavior
This works, however:
Your Environment
https://mypy-play.net/?mypy=latest&python=3.11&gist=050eb94523510217a3bf91e9977539d0
The text was updated successfully, but these errors were encountered: