summaryrefslogtreecommitdiffstats
path: root/Lib/typing.py
diff options
context:
space:
mode:
authorKen Jin <28750310+Fidget-Spinner@users.noreply.github.com>2021-12-16 14:29:59 (GMT)
committerGitHub <noreply@github.com>2021-12-16 14:29:59 (GMT)
commitd6e13747161d7b634b47d2d3d212ed3be4a21fab (patch)
tree9882b6f1113e19290e8608030310c446546bca11 /Lib/typing.py
parent4506bbede1644e985991884964b43afa7ee6f609 (diff)
downloadcpython-d6e13747161d7b634b47d2d3d212ed3be4a21fab.zip
cpython-d6e13747161d7b634b47d2d3d212ed3be4a21fab.tar.gz
cpython-d6e13747161d7b634b47d2d3d212ed3be4a21fab.tar.bz2
bpo-45755: [typing] Reveal class attributes of generic in generic aliases in `dir()` (GH-29962)
Diffstat (limited to 'Lib/typing.py')
-rw-r--r--Lib/typing.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/typing.py b/Lib/typing.py
index bdd19ca..ae1dd5c 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -991,6 +991,9 @@ class _BaseGenericAlias(_Final, _root=True):
raise TypeError("Subscripted generics cannot be used with"
" class and instance checks")
+ def __dir__(self):
+ return list(set(super().__dir__()
+ + [attr for attr in dir(self.__origin__) if not _is_dunder(attr)]))
# Special typing constructs Union, Optional, Generic, Callable and Tuple
# use three special attributes for internal bookkeeping of generic types: