diff options
author | Yurii Karabas <1998uriyyo@gmail.com> | 2021-07-19 17:22:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-19 17:22:12 (GMT) |
commit | bce1418541a64a793960182772f985f64afbfa1a (patch) | |
tree | cfde24e8cb3ad119a55282e54f4b052f8be468d9 /Lib/typing.py | |
parent | 89f4c34797de2f0e5045da2b97c1c8cbbb42fbb2 (diff) | |
download | cpython-bce1418541a64a793960182772f985f64afbfa1a.zip cpython-bce1418541a64a793960182772f985f64afbfa1a.tar.gz cpython-bce1418541a64a793960182772f985f64afbfa1a.tar.bz2 |
bpo-44524: Add missed __name__ and __qualname__ to typing module objects (#27237)
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Diffstat (limited to 'Lib/typing.py')
-rw-r--r-- | Lib/typing.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/typing.py b/Lib/typing.py index 59f3ca3..4a6efee 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -358,6 +358,12 @@ class _SpecialForm(_Final, _root=True): self._name = getitem.__name__ self.__doc__ = getitem.__doc__ + def __getattr__(self, item): + if item in {'__name__', '__qualname__'}: + return self._name + + raise AttributeError(item) + def __mro_entries__(self, bases): raise TypeError(f"Cannot subclass {self!r}") @@ -935,6 +941,9 @@ class _BaseGenericAlias(_Final, _root=True): return tuple(res) def __getattr__(self, attr): + if attr in {'__name__', '__qualname__'}: + return self._name + # We are careful for copy and pickle. # Also for simplicity we just don't relay all dunder names if '__origin__' in self.__dict__ and not _is_dunder(attr): |