Skip to content

Commit 539b167

Browse files
committed
feedback
1 parent 22c2b6e commit 539b167

File tree

2 files changed

+12
-25
lines changed

2 files changed

+12
-25
lines changed

src/test_typing_extensions.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4338,16 +4338,14 @@ class Closed(TypedDict, closed=True):
43384338
class Unclosed(TypedDict, closed=False):
43394339
...
43404340

4341-
with self.assertWarns(DeprecationWarning):
4342-
class ChildUnclosed(Closed, Unclosed):
4343-
...
4341+
class ChildUnclosed(Closed, Unclosed):
4342+
...
43444343

43454344
self.assertFalse(ChildUnclosed.__closed__)
43464345
self.assertEqual(ChildUnclosed.__extra_items__, NoExtraItems)
43474346

4348-
with self.assertWarns(DeprecationWarning):
4349-
class ChildClosed(Unclosed, Closed):
4350-
...
4347+
class ChildClosed(Unclosed, Closed):
4348+
...
43514349

43524350
self.assertFalse(ChildClosed.__closed__)
43534351
self.assertEqual(ChildClosed.__extra_items__, NoExtraItems)
@@ -4729,9 +4727,8 @@ def test_extra_keys_non_readonly_compat(self):
47294727
class Base(TypedDict, closed=True):
47304728
__extra_items__: str
47314729

4732-
with self.assertWarns(DeprecationWarning):
4733-
class Child(Base):
4734-
a: NotRequired[int]
4730+
class Child(Base):
4731+
a: NotRequired[int]
47354732

47364733
self.assertEqual(Child.__required_keys__, frozenset({}))
47374734
self.assertEqual(Child.__optional_keys__, frozenset({'a'}))
@@ -4743,14 +4740,14 @@ def test_extra_keys_readonly(self):
47434740
class Base(TypedDict, closed=True):
47444741
__extra_items__: ReadOnly[str]
47454742

4746-
with self.assertWarns(DeprecationWarning):
4747-
class Child(Base):
4748-
a: NotRequired[str]
4743+
class Child(Base):
4744+
a: NotRequired[str]
47494745

47504746
self.assertEqual(Child.__required_keys__, frozenset({}))
47514747
self.assertEqual(Child.__optional_keys__, frozenset({'a'}))
47524748
self.assertEqual(Child.__readonly_keys__, frozenset({}))
47534749
self.assertEqual(Child.__mutable_keys__, frozenset({'a'}))
4750+
47544751
@skipIf(TYPING_3_14_0, "Only supported on <3.14")
47554752
def test_extra_keys_readonly_explicit_closed(self):
47564753
class Base(TypedDict, closed=True):
@@ -4764,6 +4761,7 @@ class Child(Base, closed=True):
47644761
self.assertEqual(Child.__readonly_keys__, frozenset({}))
47654762
self.assertEqual(Child.__mutable_keys__, frozenset({'a'}))
47664763

4764+
@skipIf(TYPING_3_14_0, "Only supported on <3.14")
47674765
def test_extra_key_required(self):
47684766
with self.assertRaisesRegex(
47694767
TypeError,
@@ -4808,6 +4806,7 @@ class ExtraNotRequired(TypedDict):
48084806
self.assertEqual(ExtraNotRequired.__extra_items__, NoExtraItems)
48094807
self.assertFalse(ExtraNotRequired.__closed__)
48104808

4809+
@skipIf(TYPING_3_14_0, "Only supported on <3.14")
48114810
def test_closed_inheritance(self):
48124811
class Base(TypedDict, closed=True):
48134812
__extra_items__: ReadOnly[Union[str, None]]
@@ -4830,7 +4829,7 @@ class Child(Base, closed=True):
48304829
self.assertEqual(Child.__mutable_keys__, frozenset({'a'}))
48314830
self.assertEqual(Child.__annotations__, {"a": int})
48324831
self.assertEqual(Child.__extra_items__, int)
4833-
self.assertTrue(Child.__closed__)
4832+
self.assertIs(Child.__closed__, True)
48344833

48354834
class GrandChild(Child, closed=True):
48364835
__extra_items__: str

src/typing_extensions.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,18 +1042,6 @@ def __new__(cls, name, bases, ns, *, total=True, closed=None,
10421042
optional_keys.update(base_dict.get('__optional_keys__', ()))
10431043
readonly_keys.update(base_dict.get('__readonly_keys__', ()))
10441044
mutable_keys.update(base_dict.get('__mutable_keys__', ()))
1045-
if getattr(base, "__closed__", None) and not closed:
1046-
if sys.version_info < (3, 14):
1047-
# PEP 728 wants this to be an error, but that is not
1048-
# compatible with previous versions of typing-extensions.
1049-
warnings.warn(
1050-
"Child of a closed TypedDict must also be closed. This will "
1051-
"be an error in Python 3.14.",
1052-
DeprecationWarning,
1053-
stacklevel=2,
1054-
)
1055-
else:
1056-
raise TypeError("Child of a closed TypedDict must also be closed")
10571045

10581046
if closed and extra_items_type is NoExtraItems:
10591047
extra_items_type = Never

0 commit comments

Comments
 (0)