From a744c3746fd85720f495008e77268c83bd6e83fd Mon Sep 17 00:00:00 2001 From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Sun, 2 May 2021 13:02:14 -0700 Subject: [PATCH] ast: update for py310 (#5293) --- stdlib/_ast.pyi | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/stdlib/_ast.pyi b/stdlib/_ast.pyi index fd0bc107d..2d0d92d83 100644 --- a/stdlib/_ast.pyi +++ b/stdlib/_ast.pyi @@ -375,3 +375,37 @@ class alias(AST): class withitem(AST): context_expr: expr optional_vars: Optional[expr] + +if sys.version_info >= (3, 10): + class Match(stmt): + subject: expr + cases: typing.List[match_case] + class pattern(AST): ... + # Without the alias, Pyright complains variables named pattern are recursively defined + _pattern = pattern + class match_case(AST): + pattern: _pattern + guard: Optional[expr] + body: typing.List[stmt] + class MatchValue(pattern): + value: expr + class MatchSingleton(pattern): + value: Optional[bool] + class MatchSequence(pattern): + patterns: typing.List[pattern] + class MatchStar(pattern): + name: Optional[_identifier] + class MatchMapping(pattern): + keys: typing.List[expr] + patterns: typing.List[pattern] + rest: Optional[_identifier] + class MatchClass(pattern): + cls: expr + patterns: typing.List[pattern] + kwd_attrs: typing.List[_identifier] + kwd_patterns: typing.List[pattern] + class MatchAs(pattern): + pattern: Optional[_pattern] + name: Optional[_identifier] + class MatchOr(pattern): + patterns: typing.List[pattern]