[issue44632] Union with TypeVar does not work as intended
Ken Jin
report at bugs.python.org
Wed Jul 14 11:27:27 EDT 2021
Ken Jin <kenjin4096 at gmail.com> added the comment:
Oh this is a fun one :).
> The code for recognizing TypeVars must be wrong. Is it also wrong in e.g. list[T]?
list[T] is correct. I was pretty puzzled since I thought their code is nearly the same, but then I noticed a subtle difference -- GenericAlias checks for type(o).__module__ == "typing", while Union checks for o.__module__ == "typing", and o.__module__ is wherever the user defines it.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44632>
_______________________________________
More information about the Python-bugs-list
mailing list