|
| 1 | +import ast |
1 | 2 | import builtins |
2 | 3 | import os |
3 | 4 | import sys |
@@ -623,21 +624,6 @@ class AsyncWith(stmt): |
623 | 624 | **kwargs: Unpack[_Attributes], |
624 | 625 | ) -> Self: ... |
625 | 626 |
|
626 | | -if sys.version_info >= (3, 10): |
627 | | - class Match(stmt): |
628 | | - __match_args__ = ("subject", "cases") |
629 | | - subject: expr |
630 | | - cases: list[match_case] |
631 | | - if sys.version_info >= (3, 13): |
632 | | - def __init__(self, subject: expr, cases: list[match_case] = ..., **kwargs: Unpack[_Attributes]) -> None: ... |
633 | | - else: |
634 | | - def __init__(self, subject: expr, cases: list[match_case], **kwargs: Unpack[_Attributes]) -> None: ... |
635 | | - |
636 | | - if sys.version_info >= (3, 14): |
637 | | - def __replace__( |
638 | | - self, *, subject: expr = ..., cases: list[match_case] = ..., **kwargs: Unpack[_Attributes] |
639 | | - ) -> Self: ... |
640 | | - |
641 | 627 | class Raise(stmt): |
642 | 628 | if sys.version_info >= (3, 10): |
643 | 629 | __match_args__ = ("exc", "cause") |
@@ -1135,13 +1121,13 @@ class Subscript(expr): |
1135 | 1121 | if sys.version_info >= (3, 10): |
1136 | 1122 | __match_args__ = ("value", "slice", "ctx") |
1137 | 1123 | value: expr |
1138 | | - slice: _Slice |
| 1124 | + slice: expr |
1139 | 1125 | ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` |
1140 | | - def __init__(self, value: expr, slice: _Slice, ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ... |
| 1126 | + def __init__(self, value: expr, slice: expr, ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ... |
1141 | 1127 |
|
1142 | 1128 | if sys.version_info >= (3, 14): |
1143 | 1129 | def __replace__( |
1144 | | - self, *, value: expr = ..., slice: _Slice = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes] |
| 1130 | + self, *, value: expr = ..., slice: expr = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes] |
1145 | 1131 | ) -> Self: ... |
1146 | 1132 |
|
1147 | 1133 | class Starred(expr): |
@@ -1194,36 +1180,28 @@ class Tuple(expr): |
1194 | 1180 | @deprecated("Deprecated since Python 3.9.") |
1195 | 1181 | class slice(AST): ... |
1196 | 1182 |
|
1197 | | -_Slice: typing_extensions.TypeAlias = expr |
1198 | | -_SliceAttributes: typing_extensions.TypeAlias = _Attributes |
1199 | | - |
1200 | | -class Slice(_Slice): |
| 1183 | +class Slice(expr): |
1201 | 1184 | if sys.version_info >= (3, 10): |
1202 | 1185 | __match_args__ = ("lower", "upper", "step") |
1203 | 1186 | lower: expr | None |
1204 | 1187 | upper: expr | None |
1205 | 1188 | step: expr | None |
1206 | 1189 | def __init__( |
1207 | | - self, lower: expr | None = None, upper: expr | None = None, step: expr | None = None, **kwargs: Unpack[_SliceAttributes] |
| 1190 | + self, lower: expr | None = None, upper: expr | None = None, step: expr | None = None, **kwargs: Unpack[_Attributes] |
1208 | 1191 | ) -> None: ... |
1209 | 1192 |
|
1210 | 1193 | if sys.version_info >= (3, 14): |
1211 | 1194 | def __replace__( |
1212 | | - self, |
1213 | | - *, |
1214 | | - lower: expr | None = ..., |
1215 | | - upper: expr | None = ..., |
1216 | | - step: expr | None = ..., |
1217 | | - **kwargs: Unpack[_SliceAttributes], |
| 1195 | + self, *, lower: expr | None = ..., upper: expr | None = ..., step: expr | None = ..., **kwargs: Unpack[_Attributes] |
1218 | 1196 | ) -> Self: ... |
1219 | 1197 |
|
1220 | 1198 | @deprecated("Deprecated since Python 3.9. Use ast.Tuple instead.") |
1221 | 1199 | class ExtSlice(slice): |
1222 | | - def __new__(cls, dims: Iterable[slice] = (), **kwargs: Unpack[_SliceAttributes]) -> Tuple: ... # type: ignore[misc] |
| 1200 | + def __new__(cls, dims: Iterable[slice] = (), **kwargs: Unpack[_Attributes]) -> Tuple: ... # type: ignore[misc] |
1223 | 1201 |
|
1224 | 1202 | @deprecated("Deprecated since Python 3.9. Use the index value directly instead.") |
1225 | 1203 | class Index(slice): |
1226 | | - def __new__(cls, value: expr, **kwargs: Unpack[_SliceAttributes]) -> expr: ... # type: ignore[misc] |
| 1204 | + def __new__(cls, value: expr, **kwargs: Unpack[_Attributes]) -> expr: ... # type: ignore[misc] |
1227 | 1205 |
|
1228 | 1206 | class expr_context(AST): ... |
1229 | 1207 |
|
@@ -1465,37 +1443,48 @@ class withitem(AST): |
1465 | 1443 | def __replace__(self, *, context_expr: expr = ..., optional_vars: expr | None = ...) -> Self: ... |
1466 | 1444 |
|
1467 | 1445 | if sys.version_info >= (3, 10): |
| 1446 | + class pattern(AST): |
| 1447 | + lineno: int |
| 1448 | + col_offset: int |
| 1449 | + end_lineno: int |
| 1450 | + end_col_offset: int |
| 1451 | + def __init__(self, **kwargs: Unpack[_Attributes[int]]) -> None: ... |
| 1452 | + |
| 1453 | + if sys.version_info >= (3, 14): |
| 1454 | + def __replace__( |
| 1455 | + self, *, lineno: int = ..., col_offset: int = ..., end_lineno: int = ..., end_col_offset: int = ... |
| 1456 | + ) -> Self: ... |
| 1457 | + |
1468 | 1458 | class match_case(AST): |
1469 | 1459 | __match_args__ = ("pattern", "guard", "body") |
1470 | | - pattern: _Pattern |
| 1460 | + pattern: ast.pattern |
1471 | 1461 | guard: expr | None |
1472 | 1462 | body: list[stmt] |
1473 | 1463 | if sys.version_info >= (3, 13): |
1474 | | - def __init__(self, pattern: _Pattern, guard: expr | None = None, body: list[stmt] = ...) -> None: ... |
1475 | | - else: |
| 1464 | + def __init__(self, pattern: ast.pattern, guard: expr | None = None, body: list[stmt] = ...) -> None: ... |
| 1465 | + elif sys.version_info >= (3, 10): |
1476 | 1466 | @overload |
1477 | | - def __init__(self, pattern: _Pattern, guard: expr | None, body: list[stmt]) -> None: ... |
| 1467 | + def __init__(self, pattern: ast.pattern, guard: expr | None, body: list[stmt]) -> None: ... |
1478 | 1468 | @overload |
1479 | | - def __init__(self, pattern: _Pattern, guard: expr | None = None, *, body: list[stmt]) -> None: ... |
| 1469 | + def __init__(self, pattern: ast.pattern, guard: expr | None = None, *, body: list[stmt]) -> None: ... |
1480 | 1470 |
|
1481 | 1471 | if sys.version_info >= (3, 14): |
1482 | | - def __replace__(self, *, pattern: _Pattern = ..., guard: expr | None = ..., body: list[stmt] = ...) -> Self: ... |
| 1472 | + def __replace__(self, *, pattern: ast.pattern = ..., guard: expr | None = ..., body: list[stmt] = ...) -> Self: ... |
1483 | 1473 |
|
1484 | | - class pattern(AST): |
1485 | | - lineno: int |
1486 | | - col_offset: int |
1487 | | - end_lineno: int |
1488 | | - end_col_offset: int |
1489 | | - def __init__(self, **kwargs: Unpack[_Attributes[int]]) -> None: ... |
| 1474 | + class Match(stmt): |
| 1475 | + __match_args__ = ("subject", "cases") |
| 1476 | + subject: expr |
| 1477 | + cases: list[match_case] |
| 1478 | + if sys.version_info >= (3, 13): |
| 1479 | + def __init__(self, subject: expr, cases: list[match_case] = ..., **kwargs: Unpack[_Attributes]) -> None: ... |
| 1480 | + else: |
| 1481 | + def __init__(self, subject: expr, cases: list[match_case], **kwargs: Unpack[_Attributes]) -> None: ... |
1490 | 1482 |
|
1491 | 1483 | if sys.version_info >= (3, 14): |
1492 | 1484 | def __replace__( |
1493 | | - self, *, lineno: int = ..., col_offset: int = ..., end_lineno: int = ..., end_col_offset: int = ... |
| 1485 | + self, *, subject: expr = ..., cases: list[match_case] = ..., **kwargs: Unpack[_Attributes] |
1494 | 1486 | ) -> Self: ... |
1495 | 1487 |
|
1496 | | - # Without the alias, Pyright complains variables named pattern are recursively defined |
1497 | | - _Pattern: typing_extensions.TypeAlias = pattern |
1498 | | - |
1499 | 1488 | class MatchValue(pattern): |
1500 | 1489 | __match_args__ = ("value",) |
1501 | 1490 | value: expr |
@@ -1597,15 +1586,15 @@ if sys.version_info >= (3, 10): |
1597 | 1586 |
|
1598 | 1587 | class MatchAs(pattern): |
1599 | 1588 | __match_args__ = ("pattern", "name") |
1600 | | - pattern: _Pattern | None |
| 1589 | + pattern: ast.pattern | None |
1601 | 1590 | name: str | None |
1602 | 1591 | def __init__( |
1603 | | - self, pattern: _Pattern | None = None, name: str | None = None, **kwargs: Unpack[_Attributes[int]] |
| 1592 | + self, pattern: ast.pattern | None = None, name: str | None = None, **kwargs: Unpack[_Attributes[int]] |
1604 | 1593 | ) -> None: ... |
1605 | 1594 |
|
1606 | 1595 | if sys.version_info >= (3, 14): |
1607 | 1596 | def __replace__( |
1608 | | - self, *, pattern: _Pattern | None = ..., name: str | None = ..., **kwargs: Unpack[_Attributes[int]] |
| 1597 | + self, *, pattern: ast.pattern | None = ..., name: str | None = ..., **kwargs: Unpack[_Attributes[int]] |
1609 | 1598 | ) -> Self: ... |
1610 | 1599 |
|
1611 | 1600 | class MatchOr(pattern): |
|
0 commit comments