Skip to content

Commit ad11dc9

Browse files
committed
leave conditions
1 parent 8658a0e commit ad11dc9

File tree

1 file changed

+30
-34
lines changed

1 file changed

+30
-34
lines changed

src/typing_extensions.py

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import warnings
1616

1717
# Breakpoint: https://github.com/python/cpython/pull/119891
18-
if sys.version_info >= (3, 14, 0, "alpha", 1):
18+
if sys.version_info >= (3, 14):
1919
import annotationlib
2020

2121
__all__ = [
@@ -171,7 +171,7 @@ def __repr__(self):
171171

172172

173173
# Breakpoint: https://github.com/python/cpython/pull/27342
174-
if sys.version_info >= (3, 10, 0, "candidate"):
174+
if sys.version_info >= (3, 10):
175175
def _should_collect_from_parameters(t):
176176
return isinstance(
177177
t, (typing._GenericAlias, _types.GenericAlias, _types.UnionType)
@@ -193,7 +193,7 @@ def _should_collect_from_parameters(t):
193193

194194

195195
# Breakpoint: https://github.com/python/cpython/pull/31841
196-
if sys.version_info >= (3, 11, 0, "alpha", 7):
196+
if sys.version_info >= (3, 11):
197197
from typing import Any
198198
else:
199199

@@ -282,7 +282,7 @@ def __repr__(self):
282282
Final = typing.Final
283283

284284
# Breakpoint: https://github.com/python/cpython/pull/30530
285-
if sys.version_info >= (3, 11, 0, "alpha", 4):
285+
if sys.version_info >= (3, 11):
286286
final = typing.final
287287
else:
288288
# @final exists in 3.8+, but we backport it for all versions
@@ -598,7 +598,7 @@ def _caller(depth=1, default='__main__'):
598598
# `__match_args__` attribute was removed from protocol members in 3.13,
599599
# we want to backport this change to older Python versions.
600600
# Breakpoint: https://github.com/python/cpython/pull/110683
601-
if sys.version_info >= (3, 13, 0, "alpha", 1):
601+
if sys.version_info >= (3, 13):
602602
Protocol = typing.Protocol
603603
else:
604604
def _allow_reckless_class_checks(depth=2):
@@ -779,7 +779,7 @@ def __init_subclass__(cls, *args, **kwargs):
779779

780780

781781
# Breakpoint: https://github.com/python/cpython/pull/113401
782-
if sys.version_info >= (3, 13, 0, "alpha", 3):
782+
if sys.version_info >= (3, 13):
783783
runtime_checkable = typing.runtime_checkable
784784
else:
785785
def runtime_checkable(cls):
@@ -840,7 +840,7 @@ def close(self): ...
840840

841841
# Our version of runtime-checkable protocols is faster on Python <=3.11
842842
# Breakpoint: https://github.com/python/cpython/pull/112717
843-
if sys.version_info >= (3, 12, 0, "alpha", 3):
843+
if sys.version_info >= (3, 12):
844844
SupportsInt = typing.SupportsInt
845845
SupportsFloat = typing.SupportsFloat
846846
SupportsComplex = typing.SupportsComplex
@@ -1170,7 +1170,7 @@ def __new__(cls, name, bases, ns, *, total=True, closed=None,
11701170
readonly_keys.discard(annotation_key)
11711171

11721172
# Breakpoint: https://github.com/python/cpython/pull/119891
1173-
if sys.version_info >= (3, 14, 0, "alpha", 1):
1173+
if sys.version_info >= (3, 14):
11741174
def __annotate__(format):
11751175
annos = {}
11761176
for base in bases:
@@ -1261,7 +1261,7 @@ def _create_typeddict(
12611261
" but not both")
12621262
if kwargs:
12631263
# Breakpoint: https://github.com/python/cpython/pull/104891
1264-
if sys.version_info >= (3, 13, 0, "alpha", 1):
1264+
if sys.version_info >= (3, 13):
12651265
raise TypeError("TypedDict takes no keyword arguments")
12661266
warnings.warn(
12671267
"The kwargs-based syntax for TypedDict definitions is deprecated "
@@ -1471,7 +1471,7 @@ def get_type_hints(obj, globalns=None, localns=None, include_extras=False):
14711471
obj, globalns=globalns, localns=localns, include_extras=True
14721472
)
14731473
# Breakpoint: https://github.com/python/cpython/pull/30304
1474-
if sys.version_info < (3, 11, 0, "alpha", 6):
1474+
if sys.version_info < (3, 11):
14751475
_clean_optional(obj, hint, globalns, localns)
14761476
if include_extras:
14771477
return hint
@@ -1544,7 +1544,7 @@ def _clean_optional(obj, hints, globalns=None, localns=None):
15441544
# Python 3.9 has get_origin() and get_args() but those implementations don't support
15451545
# ParamSpecArgs and ParamSpecKwargs, so only Python 3.10's versions will do.
15461546
# Breakpoint: https://github.com/python/cpython/pull/25298
1547-
if sys.version_info >= (3, 10, 0, "beta"):
1547+
if sys.version_info >= (3, 10):
15481548
get_origin = typing.get_origin
15491549
get_args = typing.get_args
15501550
# 3.9
@@ -2111,7 +2111,7 @@ def _concatenate_getitem(self, parameters):
21112111

21122112
# 3.11+; Concatenate does not accept ellipsis in 3.10
21132113
# Breakpoint: https://github.com/python/cpython/pull/30969
2114-
if sys.version_info >= (3, 11, 0, "beta"):
2114+
if sys.version_info >= (3, 11):
21152115
Concatenate = typing.Concatenate
21162116
# <=3.10
21172117
else:
@@ -2449,7 +2449,7 @@ def foo(**kwargs: Unpack[Movie]): ...
24492449

24502450
# PEP 692 changed the repr of Unpack[]
24512451
# Breakpoint: https://github.com/python/cpython/pull/104048
2452-
if sys.version_info >= (3, 12, 0, "beta"):
2452+
if sys.version_info >= (3, 12):
24532453
Unpack = typing.Unpack
24542454

24552455
def _is_unpack(obj):
@@ -2714,7 +2714,7 @@ def int_or_str(arg: int | str) -> None:
27142714

27152715
# dataclass_transform exists in 3.11 but lacks the frozen_default parameter
27162716
# Breakpoint: https://github.com/python/cpython/pull/99958
2717-
if sys.version_info >= (3, 12, 0, "alpha", 3): # 3.12+
2717+
if sys.version_info >= (3, 12): # 3.12+
27182718
dataclass_transform = typing.dataclass_transform
27192719
else: # <=3.11
27202720
def dataclass_transform(
@@ -2976,7 +2976,7 @@ def wrapper(*args, **kwargs):
29762976

29772977
if asyncio.coroutines.iscoroutinefunction(arg):
29782978
# Breakpoint: https://github.com/python/cpython/pull/99247
2979-
if sys.version_info >= (3, 12, 0 , "alpha", 4):
2979+
if sys.version_info >= (3, 12):
29802980
wrapper = inspect.markcoroutinefunction(wrapper)
29812981
else:
29822982
wrapper._is_coroutine = asyncio.coroutines._is_coroutine
@@ -2990,7 +2990,12 @@ def wrapper(*args, **kwargs):
29902990
)
29912991

29922992
# Breakpoint: https://github.com/python/cpython/pull/23702
2993-
if sys.version_info >= (3, 10, 0, "alpha", 4):
2993+
if sys.version_info < (3, 10):
2994+
def _is_param_expr(arg):
2995+
return arg is ... or isinstance(
2996+
arg, (tuple, list, ParamSpec, _ConcatenateGenericAlias)
2997+
)
2998+
else:
29942999
def _is_param_expr(arg):
29953000
return arg is ... or isinstance(
29963001
arg,
@@ -3002,11 +3007,6 @@ def _is_param_expr(arg):
30023007
typing._ConcatenateGenericAlias,
30033008
),
30043009
)
3005-
else:
3006-
def _is_param_expr(arg):
3007-
return arg is ... or isinstance(
3008-
arg, (tuple, list, ParamSpec, _ConcatenateGenericAlias)
3009-
)
30103010

30113011

30123012
# We have to do some monkey patching to deal with the dual nature of
@@ -3067,11 +3067,7 @@ def _check_generic(cls, parameters, elen=_marker):
30673067
expect_val = f"at least {elen}"
30683068

30693069
# Breakpoint: https://github.com/python/cpython/pull/27515
3070-
things = (
3071-
"arguments"
3072-
if sys.version_info >= (3, 10, 0, "candidate")
3073-
else "parameters"
3074-
)
3070+
things = "arguments" if sys.version_info >= (3, 10) else "parameters"
30753071
raise TypeError(f"Too {'many' if alen > elen else 'few'} {things}"
30763072
f" for {cls}; actual {alen}, expected {expect_val}")
30773073
else:
@@ -3341,7 +3337,7 @@ def __new__(cls, typename, bases, ns):
33413337
# Making sure exceptions are raised in the same way
33423338
# as in "normal" classes seems most important here.
33433339
# Breakpoint: https://github.com/python/cpython/pull/95915
3344-
if sys.version_info >= (3, 12, 0, "alpha", 1):
3340+
if sys.version_info >= (3, 12):
33453341
e.add_note(msg)
33463342
raise
33473343
else:
@@ -3490,7 +3486,7 @@ class Baz(list[str]): ...
34903486
# NewType is a class on Python 3.10+, making it pickleable
34913487
# The error message for subclassing instances of NewType was improved on 3.11+
34923488
# Breakpoint: https://github.com/python/cpython/pull/30268
3493-
if sys.version_info >= (3, 11, 0, "alpha", 7):
3489+
if sys.version_info >= (3, 11):
34943490
NewType = typing.NewType
34953491
else:
34963492
class NewType:
@@ -3543,7 +3539,7 @@ def __reduce__(self):
35433539
return self.__qualname__
35443540

35453541
# Breakpoint: https://github.com/python/cpython/pull/21515
3546-
if sys.version_info >= (3, 10, 0, "alpha", 1):
3542+
if sys.version_info >= (3, 10):
35473543
# PEP 604 methods
35483544
# It doesn't make sense to have these methods on Python <3.10
35493545

@@ -3555,12 +3551,12 @@ def __ror__(self, other):
35553551

35563552

35573553
# Breakpoint: https://github.com/python/cpython/pull/124795
3558-
if sys.version_info >= (3, 14, 0, "alpha", 1):
3554+
if sys.version_info >= (3, 14):
35593555
TypeAliasType = typing.TypeAliasType
35603556
# <=3.13
35613557
else:
35623558
# Breakpoint: https://github.com/python/cpython/pull/103764
3563-
if sys.version_info >= (3, 12, 0, "beta"):
3559+
if sys.version_info >= (3, 12):
35643560
# 3.12-3.13
35653561
def _is_unionable(obj):
35663562
"""Corresponds to is_unionable() in unionobject.c in CPython."""
@@ -3756,7 +3752,7 @@ def __call__(self):
37563752
raise TypeError("Type alias is not callable")
37573753

37583754
# Breakpoint: https://github.com/python/cpython/pull/21515
3759-
if sys.version_info >= (3, 10, 0, "alpha", 1):
3755+
if sys.version_info >= (3, 10):
37603756
def __or__(self, right):
37613757
# For forward compatibility with 3.12, reject Unions
37623758
# that are not accepted by the built-in Union.
@@ -3868,7 +3864,7 @@ def __eq__(self, other: object) -> bool:
38683864
__all__.append("CapsuleType")
38693865

38703866

3871-
if sys.version_info >= (3, 14, 0, "alpha", 3):
3867+
if sys.version_info >= (3, 14):
38723868
from annotationlib import Format, get_annotations
38733869
else:
38743870
# Available since Python 3.14.0a3
@@ -4219,7 +4215,7 @@ def __call__(self, *args, **kwargs):
42194215
raise TypeError(f"{type(self).__name__!r} object is not callable")
42204216

42214217
# Breakpoint: https://github.com/python/cpython/pull/21515
4222-
if sys.version_info >= (3, 10, 0, "alpha", 1):
4218+
if sys.version_info >= (3, 10):
42234219
def __or__(self, other):
42244220
return typing.Union[self, other]
42254221

0 commit comments

Comments
 (0)