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

Declare support for Python 3.10 #2562

merged 2 commits into from Nov 14, 2021

Conversation

hugovk
Copy link
Contributor

@hugovk hugovk commented Oct 22, 2021

Description

Python 3.10 final is already tested, just needs the Trove classifier.

Checklist - did you ...

  • Add a CHANGELOG entry if necessary?
  • [n/a] Add / update tests if necessary?
  • [n/a] Add new / update outdated documentation?

Is a changelog entry needed?


By the way, Black was first released in March 2018 and took the forward-thinking view to only support Python 3.6, which was the newest release, and therefore Black hasn't needed to drop any EOL versions yet.

Python 3.6 is EOL on 2021-12-23; will Black be dropping 3.6 before the (potentially stable) 2022 Q1 release?

@@ -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.

@cooperlees
Copy link
Collaborator

Python 3.6 is EOL on 2021-12-23; will Black be dropping 3.6 before the (potentially stable) 2022 Q1 release?

I vote yes. I'm pretty sure we're all in favor to drop Python support when cpython EOL's the version. I think that's mentioned in the stable doc/policy, if not, we should add it.

@hugovk
Copy link
Contributor Author

hugovk commented Oct 22, 2021

3.6 (or supporting upstream CPython generally) isn't mentioned in the stability policy:

https://black.readthedocs.io/en/latest/the_black_code_style/index.html#stability-policy

But the stability policy PR (#2529) added this to the Python 2 FAQ:

In terms of running Black though, Python 3.6 or newer is required.

https://black.readthedocs.io/en/latest/faq.html#does-black-support-python-2

@ichard26 ichard26 added the C: packaging Installation and packaging of Black label Oct 22, 2021
@kukushking
Copy link

Hi folks, not quite sure this is the right place but shouldn't 3.10 be added to supported target versions as part of this PR, too?

@Jackenmen
Copy link
Contributor

Classifier just means that Black can run on Python 3.10, not that it can parse Python 3.10 code (which it currently can't when it comes to new syntax like match statement and parenthesized with) which is what would constitute to adding 3.10 target version.

@kukushking
Copy link

Yep, I understand - just have no idea how are you handling 3.10 story so thought I'd mention it here in case you missed it.

@kukushking
Copy link

Just found a PR that has that covered. Thanks guys 🙌

Copy link
Collaborator

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Let's add this to the changelog

@hugovk
Copy link
Contributor Author

hugovk commented Nov 14, 2021

Let's add this to the changelog

Added!

CHANGES.md Outdated Show resolved Hide resolved
@JelleZijlstra JelleZijlstra merged commit 3cb010e into psf:main Nov 14, 2021
@hugovk hugovk deleted the add-3.10 branch November 14, 2021 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: packaging Installation and packaging of Black
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants