Skip to content

Commit 83ff33a

Browse files
committed
fix lint
1 parent 610ad76 commit 83ff33a

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/test_typing_extensions.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5176,7 +5176,7 @@ class Y(TypedDict):
51765176
def test_delayed_type_check(self):
51775177
# _type_check is also applied later
51785178
class Z(TypedDict):
5179-
a: undefined
5179+
a: undefined # noqa: F821
51805180

51815181
with self.assertRaises(NameError):
51825182
Z.__annotations__
@@ -5185,15 +5185,15 @@ class Z(TypedDict):
51855185
with self.assertRaisesRegex(TypeError, "Plain typing.Final is not valid as type argument"):
51865186
Z.__annotations__
51875187

5188-
undefined = None
5188+
undefined = None # noqa: F841
51895189
self.assertEqual(Z.__annotations__, {'a': type(None)})
51905190

51915191
@skipUnless(TYPING_3_14_0, "Only supported on 3.14")
51925192
def test_deferred_evaluation(self):
51935193
class A(TypedDict):
5194-
x: NotRequired[undefined]
5195-
y: ReadOnly[undefined]
5196-
z: Required[undefined]
5194+
x: NotRequired[undefined] # noqa: F821
5195+
y: ReadOnly[undefined] # noqa: F821
5196+
z: Required[undefined] # noqa: F821
51975197

51985198
self.assertEqual(A.__required_keys__, frozenset({'y', 'z'}))
51995199
self.assertEqual(A.__optional_keys__, frozenset({'x'}))

src/typing_extensions.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,10 +1025,14 @@ def __new__(cls, name, bases, ns, *, total=True, closed=None,
10251025
if "__annotations__" in ns:
10261026
own_annotations = ns["__annotations__"]
10271027
elif sys.version_info >= (3, 14):
1028-
own_annotate = annotationlib.get_annotate_from_class_namespace(ns)
1028+
if hasattr(annotationlib, "get_annotate_from_class_namespace"):
1029+
own_annotate = annotationlib.get_annotate_from_class_namespace(ns)
1030+
else:
1031+
# 3.14.0a7 and earlier
1032+
own_annotate = ns.get("__annotate__")
10291033
if own_annotate is not None:
10301034
own_annotations = annotationlib.call_annotate_function(
1031-
own_annotate, annotationlib.Format.FORWARDREF, owner=tp_dict
1035+
own_annotate, Format.FORWARDREF, owner=tp_dict
10321036
)
10331037
else:
10341038
own_annotations = {}
@@ -1114,14 +1118,14 @@ def __annotate__(format):
11141118
if own_annotate is not None:
11151119
own = annotationlib.call_annotate_function(
11161120
own_annotate, format, owner=tp_dict)
1117-
if format != annotationlib.Format.STRING:
1121+
if format != Format.STRING:
11181122
own = {
11191123
n: typing._type_check(tp, msg, module=tp_dict.__module__)
11201124
for n, tp in own.items()
11211125
}
1122-
elif format == annotationlib.Format.STRING:
1126+
elif format == Format.STRING:
11231127
own = annotationlib.annotations_to_string(own_annotations)
1124-
elif format in (annotationlib.Format.FORWARDREF, annotationlib.Format.VALUE):
1128+
elif format in (Format.FORWARDREF, Format.VALUE):
11251129
own = own_checked_annotations
11261130
else:
11271131
raise NotImplementedError(format)

0 commit comments

Comments
 (0)