Detect '@' dotted_name '(' ')' NEWLINE
as a simple decorator (#2182)
Previously the RELAXED_DECORATOR detection would be falsely True on that example. The problem was that an argument-less parentheses pair didn't pass the `is_simple_decorator_trailer` check even it should. OTOH a parentheses pair containing an argument or more passed as expected.
This commit is contained in:
parent
a18c7bc099
commit
e42f9921e2
@ -7,6 +7,9 @@
|
|||||||
- Set `--pyi` mode if `--stdin-filename` ends in `.pyi` (#2169)
|
- Set `--pyi` mode if `--stdin-filename` ends in `.pyi` (#2169)
|
||||||
- Add `--no-diff` to black-primer to suppress formatting changes (#2187)
|
- Add `--no-diff` to black-primer to suppress formatting changes (#2187)
|
||||||
|
|
||||||
|
- Stop detecting target version as Python 3.9+ with pre-PEP-614 decorators that are
|
||||||
|
being called but with no arguments (#2182)
|
||||||
|
|
||||||
### 21.4b2
|
### 21.4b2
|
||||||
|
|
||||||
#### _Black_
|
#### _Black_
|
||||||
|
@ -5761,6 +5761,13 @@ def is_simple_decorator_trailer(node: LN, last: bool = False) -> bool:
|
|||||||
and node.children[0].type == token.DOT
|
and node.children[0].type == token.DOT
|
||||||
and node.children[1].type == token.NAME
|
and node.children[1].type == token.NAME
|
||||||
)
|
)
|
||||||
|
# last trailer can be an argument-less parentheses pair
|
||||||
|
or (
|
||||||
|
last
|
||||||
|
and len(node.children) == 2
|
||||||
|
and node.children[0].type == token.LPAR
|
||||||
|
and node.children[1].type == token.RPAR
|
||||||
|
)
|
||||||
# last trailer can be arguments
|
# last trailer can be arguments
|
||||||
or (
|
or (
|
||||||
last
|
last
|
||||||
|
@ -13,6 +13,12 @@ def f():
|
|||||||
|
|
||||||
##
|
##
|
||||||
|
|
||||||
|
@decorator()
|
||||||
|
def f():
|
||||||
|
...
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
@decorator(arg)
|
@decorator(arg)
|
||||||
def f():
|
def f():
|
||||||
...
|
...
|
||||||
|
Loading…
Reference in New Issue
Block a user