@@ -1903,15 +1903,19 @@ class _TypingEllipsis:
1903
1903
"""Internal placeholder for ... (ellipsis)."""
1904
1904
1905
1905
1906
- _TYPING_INTERNALS = ['__parameters__' , '__orig_bases__' , '__orig_class__' ,
1907
- '_is_protocol' , '_is_runtime_protocol' ]
1906
+ _TYPING_INTERNALS = frozenset ({
1907
+ '__parameters__' , '__orig_bases__' , '__orig_class__' ,
1908
+ '_is_protocol' , '_is_runtime_protocol'
1909
+ })
1908
1910
1909
- _SPECIAL_NAMES = ['__abstractmethods__' , '__annotations__' , '__dict__' , '__doc__' ,
1910
- '__init__' , '__module__' , '__new__' , '__slots__' ,
1911
- '__subclasshook__' , '__weakref__' , '__class_getitem__' ]
1911
+ _SPECIAL_NAMES = frozenset ({
1912
+ '__abstractmethods__' , '__annotations__' , '__dict__' , '__doc__' ,
1913
+ '__init__' , '__module__' , '__new__' , '__slots__' ,
1914
+ '__subclasshook__' , '__weakref__' , '__class_getitem__'
1915
+ })
1912
1916
1913
1917
# These special attributes will be not collected as protocol members.
1914
- EXCLUDED_ATTRIBUTES = _TYPING_INTERNALS + _SPECIAL_NAMES + [ '_MutableMapping__marker' ]
1918
+ EXCLUDED_ATTRIBUTES = _TYPING_INTERNALS | _SPECIAL_NAMES | { '_MutableMapping__marker' }
1915
1919
1916
1920
1917
1921
def _get_protocol_attrs (cls ):
@@ -1922,10 +1926,10 @@ def _get_protocol_attrs(cls):
1922
1926
"""
1923
1927
attrs = set ()
1924
1928
for base in cls .__mro__ [:- 1 ]: # without object
1925
- if base .__name__ in ( 'Protocol' , 'Generic' ) :
1929
+ if base .__name__ in { 'Protocol' , 'Generic' } :
1926
1930
continue
1927
1931
annotations = getattr (base , '__annotations__' , {})
1928
- for attr in list ( base .__dict__ . keys ()) + list ( annotations . keys () ):
1932
+ for attr in ( * base .__dict__ , * annotations ):
1929
1933
if not attr .startswith ('_abc_' ) and attr not in EXCLUDED_ATTRIBUTES :
1930
1934
attrs .add (attr )
1931
1935
return attrs
0 commit comments