You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to mention that using mypy 0.91 I see a more general version of this error where the resolved GenericAlias isn't type checked at all regardless of the bound on the TypeVar. That is:
I just closed #13086 as a duplicate of this issue, but @harahu notes in that issue that this bug is also present for generic type aliases that use constrained TypeVars (as well as those that use bound TypeVars):
fromtypingimportGeneric, TypeVar, TypeAliasU=TypeVar("U", bytes, str)
RestrictedTuple: TypeAlias=tuple[U]
i_am_illegal: RestrictedTuple[int] # Passes, even though this type shouldn't be possible!
@ilevkivskyi Are you sure this should be closed? I just made a minimal playground example out of the issue I pointed out in #13086, that @AlexWaygood mentioned above:
test.py:5: error: Type argument "float" of "FooIsh" must be a subtype of "str" [type-var]
test.py:9: error: Incompatible types in assignment (expression has type "str", variable has type "Union[int, float]") [assignment]
test.py:13: error: Value of type variable "U" of "RestrictedTuple" cannot be "int" [type-var]
Found 3 errors in 1 file (checked 1 source file)
This seems like the correct output to me; I think it was correct for this issue to be closed.
The "run mypy with the master branch" option on mypy playground is often quite out of sync with what mypy's actualmaster branch is, unfortunately. (I sort-of think having that option is not particularly helpful if it's not going to be automatically synced with mypy's latest commit). Note that mypy playground isn't run by mypy; it's a third-party project that you can report issues to here: https://github.com/ymyzk/mypy-playground.
Activity
UnquietCode commentedon Nov 1, 2021
I would like to mention that using mypy 0.91 I see a more general version of this error where the resolved GenericAlias isn't type checked at all regardless of the bound on the TypeVar. That is:
fails to report an error.
AlexWaygood commentedon Jul 7, 2022
I just closed #13086 as a duplicate of this issue, but @harahu notes in that issue that this bug is also present for generic type aliases that use constrained TypeVars (as well as those that use bound TypeVars):
Support ParamSpec variables in type aliases (#14159)
harahu commentedon Nov 24, 2022
@ilevkivskyi Are you sure this should be closed? I just made a minimal playground example out of the issue I pointed out in #13086, that @AlexWaygood mentioned above:
https://mypy-play.net/?mypy=master&python=3.11&flags=strict&gist=b251ba96b0e4c9632c8ba162f81280e8
This example still fails when run with mypy from the master branch.
AlexWaygood commentedon Nov 24, 2022
@harahu, if I run mypy with the
masterbranch checked out locally on this snippet:Then this is the output:
This seems like the correct output to me; I think it was correct for this issue to be closed.
The "run mypy with the
masterbranch" option on mypy playground is often quite out of sync with what mypy's actualmasterbranch is, unfortunately. (I sort-of think having that option is not particularly helpful if it's not going to be automatically synced with mypy's latest commit). Note that mypy playground isn't run by mypy; it's a third-party project that you can report issues to here: https://github.com/ymyzk/mypy-playground.harahu commentedon Nov 24, 2022
I see. You correctly pointed out where I was mistaken. I assumed playground was up to date. Sorry about the confusion.