Ensure match/case are recognized as statements (#2665)

This commit is contained in:
Batuhan Taskaya 2021-12-02 20:58:22 +03:00 committed by GitHub
parent b0c2bcc953
commit 20d7ae0676
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 0 deletions

View File

@ -13,6 +13,7 @@
`match a, *b:` (#2639) (#2659)
- Fix `match`/`case` statements that contain `match`/`case` soft keywords multiple
times, like `match re.match()` (#2661)
- Fix `case` statements with an inline body (#2665)
- Fix assignment to environment variables in Jupyter Notebooks (#2642)
- Add `flake8-simplify` and `flake8-comprehensions` plugins (#2653)
- Fix determination of f-string expression spans (#2654)

View File

@ -52,6 +52,8 @@
syms.with_stmt,
syms.funcdef,
syms.classdef,
syms.match_stmt,
syms.case_block,
}
STANDALONE_COMMENT: Final = 153
token.tok_name[STANDALONE_COMMENT] = "STANDALONE_COMMENT"

View File

@ -0,0 +1,27 @@
match something:
case b(): print(1+1)
case c(
very_complex=True,
perhaps_even_loooooooooooooooooooooooooooooooooooooong=- 1
): print(1)
case c(
very_complex=True,
perhaps_even_loooooooooooooooooooooooooooooooooooooong=-1
): print(2)
case a: pass
# output
match something:
case b():
print(1 + 1)
case c(
very_complex=True, perhaps_even_loooooooooooooooooooooooooooooooooooooong=-1
):
print(1)
case c(
very_complex=True, perhaps_even_loooooooooooooooooooooooooooooooooooooong=-1
):
print(2)
case a:
pass

View File

@ -74,6 +74,7 @@
"pattern_matching_simple",
"pattern_matching_complex",
"pattern_matching_extras",
"pattern_matching_style",
"parenthesized_context_managers",
]