File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -3056,18 +3056,31 @@ def _namedtuple_mro_entries(bases):
30563056NamedTuple .__mro_entries__ = _namedtuple_mro_entries
30573057
30583058
3059- class _NoExtraItemsType :
3059+ class _SingletonMeta (type ):
3060+ def __setattr__ (cls , attr , value ):
3061+ # TypeError is consistent with the behavior of NoneType
3062+ raise TypeError (
3063+ f"cannot set { attr !r} attribute of immutable type { cls .__name__ !r} "
3064+ )
3065+
3066+
3067+ class _NoExtraItemsType (metaclass = _SingletonMeta ):
30603068 """The type of the NoExtraItems singleton."""
30613069
30623070 __slots__ = ()
30633071
3072+ def __new__ (cls ):
3073+ return globals ().get ("NoExtraItems" ) or object .__new__ (cls )
3074+
30643075 def __repr__ (self ):
30653076 return 'typing.NoExtraItems'
30663077
30673078 def __reduce__ (self ):
30683079 return 'NoExtraItems'
30693080
30703081NoExtraItems = _NoExtraItemsType ()
3082+ del _NoExtraItemsType
3083+ del _SingletonMeta
30713084
30723085
30733086def _get_typeddict_qualifiers (annotation_type ):
You can’t perform that action at this time.
0 commit comments