Skip to content

Commit 611b3e6

Browse files
define NoExtraItems singleton in Python
1 parent 18b929b commit 611b3e6

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Lib/test/test_typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from typing import dataclass_transform
3535
from typing import no_type_check, no_type_check_decorator
3636
from typing import Type
37-
from typing import NamedTuple, NotRequired, Required, ReadOnly, TypedDict
37+
from typing import NamedTuple, NotRequired, Required, ReadOnly, TypedDict, NoExtraItems
3838
from typing import IO, TextIO, BinaryIO
3939
from typing import Pattern, Match
4040
from typing import Annotated, ForwardRef

Lib/typing.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3056,6 +3056,20 @@ def _namedtuple_mro_entries(bases):
30563056
NamedTuple.__mro_entries__ = _namedtuple_mro_entries
30573057

30583058

3059+
class _NoExtraItemsType:
3060+
"""The type of the NoExtraItems singleton."""
3061+
3062+
__slots__ = ()
3063+
3064+
def __repr__(self):
3065+
return 'typing.NoExtraItems'
3066+
3067+
def __reduce__(self):
3068+
return 'NoExtraItems'
3069+
3070+
NoExtraItems = _NoExtraItemsType()
3071+
3072+
30593073
def _get_typeddict_qualifiers(annotation_type):
30603074
while True:
30613075
annotation_origin = get_origin(annotation_type)

0 commit comments

Comments
 (0)