diff --git a/stdlib/_ast.pyi b/stdlib/_ast.pyi index eea49588c..f801b5deb 100644 --- a/stdlib/_ast.pyi +++ b/stdlib/_ast.pyi @@ -10,6 +10,8 @@ if sys.version_info >= (3, 8): _identifier = str class AST: + if sys.version_info >= (3, 10): + __match_args__ = () _attributes: ClassVar[tuple[str, ...]] _fields: ClassVar[tuple[str, ...]] def __init__(self, *args: Any, **kwargs: Any) -> None: ... @@ -27,26 +29,38 @@ if sys.version_info >= (3, 8): class type_ignore(AST): ... class TypeIgnore(type_ignore): + if sys.version_info >= (3, 10): + __match_args__ = ("lineno", "tag") tag: str class FunctionType(mod): + if sys.version_info >= (3, 10): + __match_args__ = ("argtypes", "returns") argtypes: list[expr] returns: expr class Module(mod): + if sys.version_info >= (3, 10): + __match_args__ = ("body", "type_ignores") body: list[stmt] if sys.version_info >= (3, 8): type_ignores: list[TypeIgnore] class Interactive(mod): + if sys.version_info >= (3, 10): + __match_args__ = ("body",) body: list[stmt] class Expression(mod): + if sys.version_info >= (3, 10): + __match_args__ = ("body",) body: expr class stmt(AST): ... class FunctionDef(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment") name: _identifier args: arguments body: list[stmt] @@ -54,6 +68,8 @@ class FunctionDef(stmt): returns: expr | None class AsyncFunctionDef(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment") name: _identifier args: arguments body: list[stmt] @@ -61,6 +77,8 @@ class AsyncFunctionDef(stmt): returns: expr | None class ClassDef(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("name", "bases", "keywords", "body", "decorator_list") name: _identifier bases: list[expr] keywords: list[keyword] @@ -68,85 +86,123 @@ class ClassDef(stmt): decorator_list: list[expr] class Return(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("value",) value: expr | None class Delete(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("targets",) targets: list[expr] class Assign(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("targets", "value", "type_comment") targets: list[expr] value: expr class AugAssign(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("target", "op", "value") target: expr op: operator value: expr class AnnAssign(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("target", "annotation", "value", "simple") target: expr annotation: expr value: expr | None simple: int class For(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("target", "iter", "body", "orelse", "type_comment") target: expr iter: expr body: list[stmt] orelse: list[stmt] class AsyncFor(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("target", "iter", "body", "orelse", "type_comment") target: expr iter: expr body: list[stmt] orelse: list[stmt] class While(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("test", "body", "orelse") test: expr body: list[stmt] orelse: list[stmt] class If(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("test", "body", "orelse") test: expr body: list[stmt] orelse: list[stmt] class With(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("items", "body", "type_comment") items: list[withitem] body: list[stmt] class AsyncWith(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("items", "body", "type_comment") items: list[withitem] body: list[stmt] class Raise(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("exc", "cause") exc: expr | None cause: expr | None class Try(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("body", "handlers", "orelse", "finalbody") body: list[stmt] handlers: list[ExceptHandler] orelse: list[stmt] finalbody: list[stmt] class Assert(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("test", "msg") test: expr msg: expr | None class Import(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("names",) names: list[alias] class ImportFrom(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("module", "names", "level") module: _identifier | None names: list[alias] level: int class Global(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("names",) names: list[_identifier] class Nonlocal(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("names",) names: list[_identifier] class Expr(stmt): + if sys.version_info >= (3, 10): + __match_args__ = ("value",) value: expr class Pass(stmt): ... @@ -155,76 +211,112 @@ class Continue(stmt): ... class expr(AST): ... class BoolOp(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("op", "values") op: boolop values: list[expr] class BinOp(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("left", "op", "right") left: expr op: operator right: expr class UnaryOp(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("op", "operand") op: unaryop operand: expr class Lambda(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("args", "body") args: arguments body: expr class IfExp(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("test", "body", "orelse") test: expr body: expr orelse: expr class Dict(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("keys", "values") keys: list[expr | None] values: list[expr] class Set(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("elts",) elts: list[expr] class ListComp(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("elt", "generators") elt: expr generators: list[comprehension] class SetComp(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("elt", "generators") elt: expr generators: list[comprehension] class DictComp(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("key", "value", "generators") key: expr value: expr generators: list[comprehension] class GeneratorExp(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("elt", "generators") elt: expr generators: list[comprehension] class Await(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("value",) value: expr class Yield(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("value",) value: expr | None class YieldFrom(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("value",) value: expr class Compare(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("left", "ops", "comparators") left: expr ops: list[cmpop] comparators: list[expr] class Call(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("func", "args", "keywords") func: expr args: list[expr] keywords: list[keyword] class FormattedValue(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("value", "conversion", "format_spec") value: expr conversion: int | None format_spec: expr | None class JoinedStr(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("values",) values: list[expr] if sys.version_info < (3, 8): @@ -243,6 +335,8 @@ if sys.version_info < (3, 8): class Ellipsis(expr): ... # Deprecated in 3.8; use Constant class Constant(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("value", "kind") value: Any # None, str, bytes, bool, int, float, complex, Ellipsis kind: str | None # Aliases for value, for backwards compatibility @@ -251,10 +345,14 @@ class Constant(expr): if sys.version_info >= (3, 8): class NamedExpr(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("target", "value") target: expr value: expr class Attribute(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("value", "attr", "ctx") value: expr attr: _identifier ctx: expr_context @@ -266,6 +364,8 @@ else: _SliceT = slice class Slice(_SliceT): + if sys.version_info >= (3, 10): + __match_args__ = ("lower", "upper", "step") lower: expr | None upper: expr | None step: expr | None @@ -278,23 +378,33 @@ if sys.version_info < (3, 9): value: expr class Subscript(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("value", "slice", "ctx") value: expr slice: _SliceT ctx: expr_context class Starred(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("value", "ctx") value: expr ctx: expr_context class Name(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("id", "ctx") id: _identifier ctx: expr_context class List(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("elts", "ctx") elts: list[expr] ctx: expr_context class Tuple(expr): + if sys.version_info >= (3, 10): + __match_args__ = ("elts", "ctx") elts: list[expr] ctx: expr_context @@ -346,6 +456,8 @@ class NotEq(cmpop): ... class NotIn(cmpop): ... class comprehension(AST): + if sys.version_info >= (3, 10): + __match_args__ = ("target", "iter", "ifs", "is_async") target: expr iter: expr ifs: list[expr] @@ -354,11 +466,15 @@ class comprehension(AST): class excepthandler(AST): ... class ExceptHandler(excepthandler): + if sys.version_info >= (3, 10): + __match_args__ = ("type", "name", "body") type: expr | None name: _identifier | None body: list[stmt] class arguments(AST): + if sys.version_info >= (3, 10): + __match_args__ = ("posonlyargs", "args", "vararg", "kwonlyargs", "kw_defaults", "kwarg", "defaults") if sys.version_info >= (3, 8): posonlyargs: list[arg] args: list[arg] @@ -369,23 +485,32 @@ class arguments(AST): defaults: list[expr] class arg(AST): + if sys.version_info >= (3, 10): + __match_args__ = ("arg", "annotation", "type_comment") arg: _identifier annotation: expr | None class keyword(AST): + if sys.version_info >= (3, 10): + __match_args__ = ("arg", "value") arg: _identifier | None value: expr class alias(AST): + if sys.version_info >= (3, 10): + __match_args__ = ("name", "asname") name: _identifier asname: _identifier | None class withitem(AST): + if sys.version_info >= (3, 10): + __match_args__ = ("context_expr", "optional_vars") context_expr: expr optional_vars: expr | None if sys.version_info >= (3, 10): class Match(stmt): + __match_args__ = ("subject", "cases") subject: expr cases: list[match_case] @@ -394,36 +519,45 @@ if sys.version_info >= (3, 10): _pattern = pattern class match_case(AST): + __match_args__ = ("pattern", "guard", "body") pattern: _pattern guard: expr | None body: list[stmt] class MatchValue(pattern): + __match_args__ = ("value",) value: expr class MatchSingleton(pattern): + __match_args__ = ("value",) value: Literal[True, False, None] class MatchSequence(pattern): + __match_args__ = ("patterns",) patterns: list[pattern] class MatchStar(pattern): + __match_args__ = ("name",) name: _identifier | None class MatchMapping(pattern): + __match_args__ = ("keys", "patterns", "rest") keys: list[expr] patterns: list[pattern] rest: _identifier | None class MatchClass(pattern): + __match_args__ = ("cls", "patterns", "kwd_attrs", "kwd_patterns") cls: expr patterns: list[pattern] kwd_attrs: list[_identifier] kwd_patterns: list[pattern] class MatchAs(pattern): + __match_args__ = ("pattern", "name") pattern: _pattern | None name: _identifier | None class MatchOr(pattern): + __match_args__ = ("patterns",) patterns: list[pattern] diff --git a/stdlib/_thread.pyi b/stdlib/_thread.pyi index be66e6869..04abf8dc8 100644 --- a/stdlib/_thread.pyi +++ b/stdlib/_thread.pyi @@ -3,7 +3,7 @@ from _typeshed import structseq from threading import Thread from types import TracebackType from typing import Any, Callable, NoReturn -from typing_extensions import final +from typing_extensions import Final, final error = RuntimeError @@ -34,6 +34,8 @@ if sys.version_info >= (3, 8): def get_native_id() -> int: ... # only available on some platforms @final class _ExceptHookArgs(structseq[Any], tuple[type[BaseException], BaseException | None, TracebackType | None, Thread | None]): + if sys.version_info >= (3, 10): + __match_args__: Final = ("exc_type", "exc_value", "exc_traceback", "thread") @property def exc_type(self) -> type[BaseException]: ... @property diff --git a/stdlib/concurrent/futures/_base.pyi b/stdlib/concurrent/futures/_base.pyi index cf822fc55..ce2a92eef 100644 --- a/stdlib/concurrent/futures/_base.pyi +++ b/stdlib/concurrent/futures/_base.pyi @@ -79,6 +79,8 @@ def as_completed(fs: Iterable[Future[_T]], timeout: float | None = ...) -> Itera # Ideally this would be a namedtuple, but mypy doesn't support generic tuple types. See #1976 class DoneAndNotDoneFutures(Sequence[set[Future[_T]]]): + if sys.version_info >= (3, 10): + __match_args__ = ("done", "not_done") @property def done(self) -> set[Future[_T]]: ... @property diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 1703684c7..fe9264975 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -35,7 +35,7 @@ from typing import ( overload, runtime_checkable, ) -from typing_extensions import Literal, final +from typing_extensions import Final, Literal, final from . import path as _path @@ -314,6 +314,8 @@ class stat_result(structseq[float], tuple[int, int, int, int, int, int, int, flo # st_uid, st_gid, st_size, st_atime, st_mtime, st_ctime. # # More items may be added at the end by some implementations. + if sys.version_info >= (3, 10): + __match_args__: Final = ("st_mode", "st_ino", "st_dev", "st_nlink", "st_uid", "st_gid", "st_size") @property def st_mode(self) -> int: ... # protection bits, @property @@ -408,6 +410,19 @@ else: @final class statvfs_result(structseq[int], _StatVfsTuple): + if sys.version_info >= (3, 10): + __match_args__: Final = ( + "f_bsize", + "f_frsize", + "f_blocks", + "f_bfree", + "f_bavail", + "f_files", + "f_ffree", + "f_favail", + "f_flag", + "f_namemax", + ) @property def f_bsize(self) -> int: ... @property @@ -449,6 +464,8 @@ def strerror(__code: int) -> str: ... def umask(__mask: int) -> int: ... @final class uname_result(structseq[str], tuple[str, str, str, str, str]): + if sys.version_info >= (3, 10): + __match_args__: Final = ("sysname", "nodename", "release", "version", "machine") @property def sysname(self) -> str: ... @property @@ -654,6 +671,8 @@ if sys.platform != "win32": @final class terminal_size(structseq[int], tuple[int, int]): + if sys.version_info >= (3, 10): + __match_args__: Final = ("columns", "lines") @property def columns(self) -> int: ... @property @@ -873,6 +892,8 @@ else: def system(command: StrOrBytesPath) -> int: ... @final class times_result(structseq[float], tuple[float, float, float, float, float]): + if sys.version_info >= (3, 10): + __match_args__: Final = ("user", "system", "children_user", "children_system", "elapsed") @property def user(self) -> float: ... @property diff --git a/stdlib/time.pyi b/stdlib/time.pyi index 844aba90f..25f8d7056 100644 --- a/stdlib/time.pyi +++ b/stdlib/time.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import structseq from typing import Any, Protocol -from typing_extensions import Literal, final +from typing_extensions import Final, Literal, final _TimeTuple = tuple[int, int, int, int, int, int, int, int, int] @@ -38,6 +38,8 @@ if sys.version_info >= (3, 9) and sys.platform == "linux": # https://github.com/python/typeshed/pull/6560#discussion_r767162532 @final class struct_time(structseq[Any | int], _TimeTuple): + if sys.version_info >= (3, 10): + __match_args__: Final = ("tm_year", "tm_mon", "tm_mday", "tm_hour", "tm_min", "tm_sec", "tm_wday", "tm_yday", "tm_isdst") @property def tm_year(self) -> int: ... @property diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index f8ba0988c..a45e23dd9 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -64,6 +64,8 @@ class _NetlocResultMixinStr(_NetlocResultMixinBase[str], _ResultMixinStr): ... class _NetlocResultMixinBytes(_NetlocResultMixinBase[bytes], _ResultMixinBytes): ... class _DefragResultBase(tuple[Any, ...], Generic[AnyStr]): + if sys.version_info >= (3, 10): + __match_args__ = ("url", "fragment") @property def url(self) -> AnyStr: ... @property