8000 Fix `Protocol` tests on Python 3.13.0b1 (#376) · python/typing_extensions@132685b · GitHub
[go: up one dir, main page]

Skip to content

Commit 132685b

Browse files
authored
Fix Protocol tests on Python 3.13.0b1 (#376)
1 parent 9a62a45 commit 132685b

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Unreleased
22

3-
- Fix tests on Python 3.13.0a6. 3.13.0a6 adds a new
3+
- Fix tests on Python 3.13.0a6 and newer. 3.13.0a6 adds a new
44
`__static_attributes__` attribute to all classes in Python,
55
which broke some assumptions made by the implementation of
6-
`typing_extensions.Protocol`.
6+
`typing_extensions.Protocol`. Similarly, 3.13.0b1 adds the new
7+
`__firstlineno__` attribute to all classes.
78
- Fix `AttributeError` when using `typing_extensions.runtime_checkable`
89
in combination with `typing.Protocol` on Python 3.12.2 or newer.
910
Patch by Alex Waygood.

src/typing_extensions.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -427,26 +427,11 @@ def clear_overloads():
427427
}
428428

429429

430-
_EXCLUDED_ATTRS = {
431-
"__abstractmethods__", "__annotations__", "__weakref__", "_is_protocol",
432-
"_is_runtime_protocol", "__dict__", "__slots__", "__parameters__",
433-
"__orig_bases__", "__module__", "_MutableMapping__marker", "__doc__",
434-
"__subclasshook__", "__orig_class__", "__init__", "__new__",
435-
"__protocol_attrs__", "__non_callable_proto_members__",
436-
"__match_args__",
430+
_EXCLUDED_ATTRS = frozenset(typing.EXCLUDED_ATTRIBUTES) | {
431+
"__match_args__", "__protocol_attrs__", "__non_callable_proto_members__",
432+
"__final__",
437433
}
438434

439-
if sys.version_info >= (3, 9):
440-
_EXCLUDED_ATTRS.add("__class_getitem__")
441-
442-
if sys.version_info >= (3, 12):
443-
_EXCLUDED_ATTRS.add("__type_params__")
444-
445-
if sys.version_info >= (3, 13):
446-
_EXCLUDED_ATTRS.add("__static_attributes__")
447-
448-
_EXCLUDED_ATTRS = frozenset(_EXCLUDED_ATTRS)
449-
450435

451436
def _get_protocol_attrs(cls):
452437
attrs = set()

0 commit comments

Comments
 (0)
0