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
PEP 614 support #1717
PEP 614 support #1717
Conversation
I'm looking for help on the space after |
For the whitespace issue, this will need to be handled in Please add a couple of explicit test cases for the feature detection, as well as some more complex decorator examples. |
src/black/__init__.py
Outdated
|
||
|
||
def is_simple_decorator_expression(node: LN) -> bool: | ||
"""Return True iff `node` is the 'dotted name' in the grammar @ dotted_name [arguments] NEWLINE""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
"""Return True iff `node` is the 'dotted name' in the grammar @ dotted_name [arguments] NEWLINE""" | |
"""Return True iff `node` is the 'namedexpr_test' in the grammar @ namedexpr_test [arguments] NEWLINE""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried to clarify that this function does test against a dotted_name
grammar. Is this better ?
Also feel free to put this PR in draft mode and ping me explicitly if you need more help until you're ready to publish it :) |
I should have checked here earlier, I just found the |
Hi @zsol , I'm not sure how to handle the following: the Still, python 3.9 code cannot be safely reformatted used python <=3.8.5. What is the best way to handle that ? Should I introduce a call to |
Also, I tried running |
The idea behind that
|
I'm not sure about primer. What kinds of changes are there? CI looks green |
I changed Sorry I forgot the details about |
Just found out that I think |
This reverts commit 3073d07.
I went through all changes reported by
All in all, every formatting I saw is due to a well-defined rule explained in the code style, so I think this PR is ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good apart from one nit
tests/data/decorators.py
Outdated
# Those before the 'output' comment are valid under the old syntax | ||
# Those after the 'ouput' comment require PEP614 relaxed syntax | ||
# Do not remove the double # separator before the first test case, it allows | ||
# to the comment before the test case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove "to"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I also forgot the verb. It should be fixed now. Thanks !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for taking the time to work on this
My pleasure :) Thanks to you two for your help. And thank everyone for Black, it is awesome ! |
https://pypi.org/project/black/ 21.5b2 was released on May 31, 2021. The current version 20.8 was released ~August 2020. `py39` was added in September 2020 with psf/black#1717.
Adds support for PEP 614 to fix #1711. This is still WIP
Changes
typed-ast
to1.4.1
so thatpipenv install --dev
doesn't fail within a python 3.9 venv due to compile errorsdecorator
inblib2to3/Grammar.txt
to reflect the relaxed decorator syntaxPY39
targetRELAXED_DECORATORS
featureget_feature_used()
, with helper functionsPY36_VERSIONS
fromsrc/black/__init__.py
totests/test_black.py
RELAXED_DECORATORS
featureNote
--safe
doesn't work on python 3.9 code from black running on python <=3.8.5. This might already be the case with python 3.8 code formatted from black running on python 3.7, becausetyped_ast
doesn't support python 3.8+ syntax. So older python version cannot parse the syntax with either the builtinast
ortyped_ast