-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
C: target versionRelated to --target-version, e.g. autodetectionRelated to --target-version, e.g. autodetectionS: needs discussionNeeds further hashing out before ready for implementation (on desirability, feasibility, etc.)Needs further hashing out before ready for implementation (on desirability, feasibility, etc.)T: enhancementNew feature or requestNew feature or request
Description
Describe the bug
PEP 634 introduces structural pattern matching in python 3.10. Black at 21.11b1 (latest) does not seem to support this new syntax.
To Reproduce
Here is a basic example of the new syntax, which we will save in match_test.py:
foo = "str"
match foo:
case str():
print("string!")
case int():
print("int!")
case _:
print("something else!")> python --version
Python 3.10.0
> python match_test.py
string!
> python -m black --version
python -m black, 21.11b1 (compiled: no)
> python -m black match_test.py
error: cannot format match_test.py: Cannot parse: 2:6: match foo:
Oh no! 💥 💔 💥
1 file failed to reformat.
Expected behavior
Structural pattern matching (and all other new python 3.10 syntax) should be fully supported.
Environment
- Black's version: 21.11b1
- OS and Python version: Ubuntu 20.04.3 LTS/Python 3.10.0
lpil and holmanb
Metadata
Metadata
Assignees
Labels
C: target versionRelated to --target-version, e.g. autodetectionRelated to --target-version, e.g. autodetectionS: needs discussionNeeds further hashing out before ready for implementation (on desirability, feasibility, etc.)Needs further hashing out before ready for implementation (on desirability, feasibility, etc.)T: enhancementNew feature or requestNew feature or request