From 2f3fa1f6d0cbc2a3f31c7440c422da173b068e7b Mon Sep 17 00:00:00 2001 From: Zac Hatfield-Dodds Date: Tue, 12 Oct 2021 15:45:58 +1100 Subject: [PATCH 1/2] Fix feature detection for positional-only arguments in lambdas (#2532) --- CHANGES.md | 1 + src/black/__init__.py | 6 +++++- tests/test_black.py | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index f5b11de4803..864f0a54410 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ ### _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_ diff --git a/src/black/__init__.py b/src/black/__init__.py index 83a39234d38..fdbaf040d64 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -1123,7 +1123,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 f25db1b73d1..beb56cf1fdb 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") From 847d468b828faff7daae297d8a20d899d2259824 Mon Sep 17 00:00:00 2001 From: Marco Edward Gorelli Date: Tue, 19 Oct 2021 18:52:10 +0100 Subject: [PATCH 2/2] bump sphinx so it works on Python3.10 (#2546) --- docs/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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