-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
C: parserHow we parse code. Or fail to parse it.How we parse code. Or fail to parse it.T: bugSomething isn't workingSomething isn't working
Description
Describe the bug
When black encounters access of a .type attribute inside brackets, inside a switch statement, it thinks that it is invalid syntax, even though python 3.11 executes it just fine.
To Reproduce
For example, take this code:
class SomeClass:
type = ""
match (SomeClass.type):
case _:
print("Hello there ...")And run it with these arguments:
$ pipx run --python python3.11 --spec=black==23.7.0 black --target-version py311 --diff file.pyThe resulting error is:
error: cannot format file.py: Cannot parse: 5:0: match (SomeClass.type):
Expected behavior
It should leave the file unchanged or format it, as black 23.3.0 leaves it unchanged, and it is indeed valid syntax:
$ python3.11 --version
Python 3.11.4
$ python3.11 file.py
Hello there ...
$ pipx run --python python3.11 --spec=black==23.3.0 black --target-version py311 --diff file.py
⚠️ black is already on your PATH and installed at /home/iwana/.local/bin/black. Downloading and running anyway.
All done! ✨ 🍰 ✨
1 file would be left unchanged.Environment
- Black's version: 23.3.0
- OS and Python version: Linux/Python 3.11.4
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C: parserHow we parse code. Or fail to parse it.How we parse code. Or fail to parse it.T: bugSomething isn't workingSomething isn't working