]> 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:

Fix feature detection for positional-only arguments in lambdas (#2532)
authorZac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
Tue, 12 Oct 2021 04:45:58 +0000 (15:45 +1100)
committerGitHub <noreply@github.com>
Tue, 12 Oct 2021 04:45:58 +0000 (21:45 -0700)
CHANGES.md
src/black/__init__.py
tests/test_black.py

index f5b11de48032bfb2712a52593b3495bfe1ef76a4..864f0a54410b33cadeaa8ee9b2a5d3817aa9c9d1 100644 (file)
@@ -5,6 +5,7 @@
 ### _Black_
 
 - Add new `--workers` parameter (#2514)
 ### _Black_
 
 - Add new `--workers` parameter (#2514)
+- Fixed feature detection for positional-only arguments in lambdas (#2532)
 - Bumped typed-ast version minimum to 1.4.3 for 3.10 compatiblity (#2519)
 
 ### _Blackd_
 - Bumped typed-ast version minimum to 1.4.3 for 3.10 compatiblity (#2519)
 
 ### _Blackd_
index 83a39234d38d1fd0ac3e506f187b022cb31d542b..fdbaf040d642b0a41d15d0f98112090971425643 100644 (file)
@@ -1123,7 +1123,11 @@ def get_features_used(node: Node) -> Set[Feature]:
                 features.add(Feature.NUMERIC_UNDERSCORES)
 
         elif n.type == token.SLASH:
                 features.add(Feature.NUMERIC_UNDERSCORES)
 
         elif n.type == token.SLASH:
-            if n.parent and n.parent.type in {syms.typedargslist, syms.arglist}:
+            if n.parent and n.parent.type in {
+                syms.typedargslist,
+                syms.arglist,
+                syms.varargslist,
+            }:
                 features.add(Feature.POS_ONLY_ARGUMENTS)
 
         elif n.type == token.COLONEQUAL:
                 features.add(Feature.POS_ONLY_ARGUMENTS)
 
         elif n.type == token.COLONEQUAL:
index f25db1b73d1ef9b102cce37ae1c89fe3566efbb4..beb56cf1fdb24bde7256366f0aa1ebf7acb23f60 100644 (file)
@@ -805,6 +805,10 @@ class BlackTestCase(BlackBaseTestCase):
         self.assertEqual(black.get_features_used(node), set())
         node = black.lib2to3_parse(expected)
         self.assertEqual(black.get_features_used(node), set())
         self.assertEqual(black.get_features_used(node), set())
         node = black.lib2to3_parse(expected)
         self.assertEqual(black.get_features_used(node), set())
+        node = black.lib2to3_parse("lambda a, /, b: ...")
+        self.assertEqual(black.get_features_used(node), {Feature.POS_ONLY_ARGUMENTS})
+        node = black.lib2to3_parse("def fn(a, /, b): ...")
+        self.assertEqual(black.get_features_used(node), {Feature.POS_ONLY_ARGUMENTS})
 
     def test_get_future_imports(self) -> None:
         node = black.lib2to3_parse("\n")
 
     def test_get_future_imports(self) -> None:
         node = black.lib2to3_parse("\n")