|
52 | 52 | # 3.12 changes the representation of Unpack[] (PEP 692)
|
53 | 53 | TYPING_3_12_0 = sys.version_info[:3] >= (3, 12, 0)
|
54 | 54 |
|
| 55 | +# 3.13 drops support for the keyword argument syntax of TypedDict |
| 56 | +TYPING_3_13_0 = sys.version_info[:3] >= (3, 13, 0) |
| 57 | + |
55 | 58 | # https://github.com/python/cpython/pull/27017 was backported into some 3.9 and 3.10
|
56 | 59 | # versions, but not all
|
57 | 60 | HAS_FORWARD_MODULE = "module" in inspect.signature(typing._type_check).parameters
|
@@ -4223,13 +4226,13 @@ class Child(Base):
|
4223 | 4226 | def test_extra_key_required(self):
|
4224 | 4227 | with self.assertRaisesRegex(
|
4225 | 4228 | TypeError,
|
4226 |
| - "Special key __extra_items__ does not support Required and NotRequired" |
| 4229 | + "Special key __extra_items__ does not support Required" |
4227 | 4230 | ):
|
4228 | 4231 | TypedDict("A", {"__extra_items__": Required[int]}, closed=True)
|
4229 | 4232 |
|
4230 | 4233 | with self.assertRaisesRegex(
|
4231 | 4234 | TypeError,
|
4232 |
| - "Special key __extra_items__ does not support Required and NotRequired" |
| 4235 | + "Special key __extra_items__ does not support NotRequired" |
4233 | 4236 | ):
|
4234 | 4237 | TypedDict("A", {"__extra_items__": NotRequired[int]}, closed=True)
|
4235 | 4238 |
|
@@ -4318,6 +4321,11 @@ class ChildB(Base, closed=True):
|
4318 | 4321 | self.assertEqual(ChildB.__extra_items__, type(None))
|
4319 | 4322 | self.assertTrue(ChildB.__closed__)
|
4320 | 4323 |
|
| 4324 | + skipIf( |
| 4325 | + TYPING_3_13_0, |
| 4326 | + "The keyword argument alternative to define a " |
| 4327 | + "TypedDict type using the functional syntax is no longer supported" |
| 4328 | + ) |
4321 | 4329 | def test_backwards_compatibility(self):
|
4322 | 4330 | with self.assertWarns(DeprecationWarning):
|
4323 | 4331 | TD = TypedDict("TD", closed=int)
|
|
0 commit comments