Skip to content

Commit 406aff6

Browse files
Change flag name to __typing_is_deprecated_inherited_runtime_protocol__
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
1 parent 1736d55 commit 406aff6

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

Lib/test/test_typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3885,7 +3885,7 @@ def meth(self): pass
38853885
self.assertIsNot(get_protocol_members(PR), P.__protocol_attrs__)
38863886

38873887
acceptable_extra_attrs = {
3888-
'_is_protocol', '_is_runtime_protocol', '_is_deprecated_inherited_runtime_protocol',
3888+
'_is_protocol', '_is_runtime_protocol', '__typing_is_deprecated_inherited_runtime_protocol__',
38893889
'__parameters__', '__init__', '__annotations__', '__subclasshook__', '__annotate__',
38903890
'__annotations_cache__', '__annotate_func__',
38913891
}

Lib/typing.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,8 +1825,9 @@ class _TypingEllipsis:
18251825

18261826
_TYPING_INTERNALS = frozenset({
18271827
'__parameters__', '__orig_bases__', '__orig_class__',
1828-
'_is_protocol', '_is_runtime_protocol', '_is_deprecated_inherited_runtime_protocol',
1829-
'__protocol_attrs__', '__non_callable_proto_members__', '__type_params__',
1828+
'_is_protocol', '_is_runtime_protocol', '__protocol_attrs__',
1829+
'__typing_is_deprecated_inherited_runtime_protocol__',
1830+
'__non_callable_proto_members__', '__type_params__',
18301831
})
18311832

18321833
_SPECIAL_NAMES = frozenset({
@@ -2015,7 +2016,7 @@ def __subclasscheck__(cls, other):
20152016
"Instance and class checks can only be used with "
20162017
"@runtime_checkable protocols"
20172018
)
2018-
if getattr(cls, '_is_deprecated_inherited_runtime_protocol', False):
2019+
if getattr(cls, '__typing_is_deprecated_inherited_runtime_protocol__', False):
20192020
# See GH-132604.
20202021
import warnings
20212022
depr_message = (
@@ -2054,7 +2055,7 @@ def __instancecheck__(cls, instance):
20542055
raise TypeError("Instance and class checks can only be used with"
20552056
" @runtime_checkable protocols")
20562057

2057-
if getattr(cls, '_is_deprecated_inherited_runtime_protocol', False):
2058+
if getattr(cls, '__typing_is_deprecated_inherited_runtime_protocol__', False):
20582059
# See GH-132604.
20592060
import warnings
20602061

@@ -2161,7 +2162,7 @@ def __init_subclass__(cls, *args, **kwargs):
21612162
# Mark inherited runtime checkability (deprecated). See GH-132604.
21622163
if cls._is_protocol and getattr(cls, '_is_runtime_protocol', False):
21632164
# This flag is set to False by @runtime_checkable.
2164-
cls._is_deprecated_inherited_runtime_protocol = True
2165+
cls.__typing_is_deprecated_inherited_runtime_protocol__ = True
21652166

21662167
# Set (or override) the protocol subclass hook.
21672168
if '__subclasshook__' not in cls.__dict__:
@@ -2310,8 +2311,8 @@ def close(self): ...
23102311
' got %r' % cls)
23112312
cls._is_runtime_protocol = True
23122313
# See GH-132604.
2313-
if hasattr(cls, '_is_deprecated_inherited_runtime_protocol'):
2314-
cls._is_deprecated_inherited_runtime_protocol = False
2314+
if hasattr(cls, '__typing_is_deprecated_inherited_runtime_protocol__'):
2315+
cls.__typing_is_deprecated_inherited_runtime_protocol__ = False
23152316
# PEP 544 prohibits using issubclass()
23162317
# with protocols that have non-method members.
23172318
# See gh-113320 for why we compute this attribute here,

0 commit comments

Comments
 (0)