Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declare support for Python 3.10 #2562

Merged
merged 2 commits into from Nov 14, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -10,6 +10,7 @@
- Add partial support for the match statement. As it's experimental, it's only enabled
when `--target-version py310` is explicitly specified (#2586)
- Add support for parenthesized with (#2586)
- Declare support for Python 3.10 (#2562)
JelleZijlstra marked this conversation as resolved.
Show resolved Hide resolved

## 21.10b0

Expand Down
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -104,6 +104,7 @@ def get_long_description() -> str:
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we wish to do this before we support all the syntax?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, probably not!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already declare Python 3.9 support without formatting all such syntax (e.g. parenthesised context managers), so I'd support adding this classifier - black does run on 3.10 after all!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it crashes if you have the new syntax elements. We don’t crash on context managers. Or has that been fixed? If so, sure. Let’s add away.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ cat 1.py
def http_error(status):
    match status:
        case 400:
            return "Bad request"
        case 404:
            return "Not found"
        case 418:
            return "I'm a teapot"
        case _:
            return "Something's wrong with the internet"
$ black 1.py
error: cannot format 1.py: Cannot parse: 2:10:     match status:
Oh no! 💥 💔 💥
1 file failed to reformat.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we do crash on context managers: see #1948, #2318 and

$ cat 2.py
from contextlib import nullcontext
with (
    nullcontext() as a,
    nullcontext() as b,
):
    pass

$ python3.9 2.py
$ black 2.py
error: cannot format 2.py: Cannot parse: 4:18:     nullcontext() as a,
Oh no! 💥 💔 💥
1 file failed to reformat.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But parenthesized CMs are an undocumented feature in 3.9, not a flagship new feature like pattern matching in 3.10.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP-614 "relaxed grammar restrictions on decorators" is documented in the what's new page, and also crashes.

"Programming Language :: Python :: 3 :: Only",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Quality Assurance",
Expand Down