mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
bpo-45755: [typing] Reveal class attributes of generic in generic aliases in dir()
(GH-29962)
This commit is contained in:
parent
4506bbede1
commit
d6e1374716
3 changed files with 17 additions and 0 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue