]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Detect `'@' dotted_name '(' ')' NEWLINE` as a simple decorator (#2182)
authorRichard Si <63936253+ichard26@users.noreply.github.com>
Tue, 4 May 2021 08:46:46 +0000 (04:46 -0400)
committerGitHub <noreply@github.com>
Tue, 4 May 2021 08:46:46 +0000 (10:46 +0200)
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.

CHANGES.md
src/black/__init__.py
tests/data/decorators.py

index 7741d92772d1065e88b65d90c543e5852fb4070c..00d6782dc6b09198e3550b6ce0ad487c4653e381 100644 (file)
@@ -7,6 +7,9 @@
 - Set `--pyi` mode if `--stdin-filename` ends in `.pyi` (#2169)
 - Add `--no-diff` to black-primer to suppress formatting changes (#2187)
 
 - Set `--pyi` mode if `--stdin-filename` ends in `.pyi` (#2169)
 - 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
 
 #### _Black_
 ### 21.4b2
 
 #### _Black_
index 49d088b531d0bc48f3340f576db6659ad0da8a03..cf257876c035c27d94c1348212a55fc59a7e7f64 100644 (file)
@@ -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[1].type == token.NAME
         )
             and node.children[0].type == token.DOT
             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
         or (
             last
         # last trailer can be arguments
         or (
             last
index acfad51fcb8ddee843314f64868821baaed717e9..a0f38ca7b9d411c3d82ca11dafffc77a466dc7ba 100644 (file)
@@ -13,6 +13,12 @@ def f():
 
 ##
 
 
 ##
 
+@decorator()
+def f():
+    ...
+
+##
+
 @decorator(arg)
 def f():
     ...
 @decorator(arg)
 def f():
     ...