Skip to content

Commit 35f53fe

Browse files
committed
factor out condition
1 parent 0bc7fe6 commit 35f53fe

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/typing_extensions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,9 @@ def inner(func):
878878
return inner
879879

880880

881-
if not hasattr(typing, "NoDefault") or not hasattr(typing, "NoExtraItems"):
881+
_NEEDS_SINGLETONMETA = not hasattr(typing, "NoDefault") or not hasattr(typing, "NoExtraItems")
882+
883+
if _NEEDS_SINGLETONMETA:
882884
class SingletonMeta(type):
883885
def __setattr__(cls, attr, value):
884886
# TypeError is consistent with the behavior of NoneType
@@ -927,7 +929,7 @@ def __reduce__(self):
927929
NoExtraItems = NoExtraItemsType()
928930
del NoExtraItemsType
929931

930-
if not hasattr(typing, "NoDefault") or not hasattr(typing, "NoExtraItems"):
932+
if _NEEDS_SINGLETONMETA:
931933
del SingletonMeta
932934

933935

0 commit comments

Comments
 (0)