diff --git a/CHANGES.md b/CHANGES.md index 8790263aa7d..aa709fa461c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,8 @@ - Add new `--workers` parameter (#2514) - Bumped typed-ast version minimum to 1.4.3 for 3.10 compatibility (#2519) +- Fixed feature detection for positional-only arguments in lambdas (#2532) +- Bumped typed-ast version minimum to 1.4.3 for 3.10 compatiblity (#2519) - Allow specifying `config` in config files (#2525) ### _Blackd_ diff --git a/docs/requirements.txt b/docs/requirements.txt index 4c5b700412a..296efc5cc84 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,6 +1,6 @@ # Used by ReadTheDocs; pinned requirements for stability. myst-parser==0.15.1 -Sphinx==4.1.2 +Sphinx==4.2.0 sphinxcontrib-programoutput==0.17 sphinx_copybutton==0.4.0 diff --git a/src/black/__init__.py b/src/black/__init__.py index b8c086ad9a1..21b966113ef 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -1125,7 +1125,11 @@ def get_features_used(node: Node) -> Set[Feature]: 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: diff --git a/tests/test_black.py b/tests/test_black.py index b672425bba8..4fb2423593a 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -805,6 +805,10 @@ def test_get_features_used(self) -> None: 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")