Repository: psf/black

Issue:
Extended R.H.S. on annotated assignments should imply Python 3.8+
Before 3.8 (through 3.6-3.7) the annotated assignment's R.H.S. value can be only simple `test`: `a: int = 1` or `a: Tuple[int, ...] = (1, 2)`. Starting with 3.8, it now accepts `a: Tuple[int, ...] = 1, 2` or even `a: Tuple[int, ...] = b, *c, d`


Discussion:

Resolving patch:
diff --git a/src/black/__init__.py b/src/black/__init__.py
--- a/src/black/__init__.py
+++ b/src/black/__init__.py
@@ -1218,6 +1218,13 @@ def get_features_used(  # noqa: C901
         ):
             features.add(Feature.UNPACKING_ON_FLOW)
 
+        elif (
+            n.type == syms.annassign
+            and len(n.children) >= 4
+            and n.children[3].type == syms.testlist_star_expr
+        ):
+            features.add(Feature.ANN_ASSIGN_EXTENDED_RHS)
+
         # Python 2 only features (for its deprecation) except for integers, see above
         elif n.type == syms.print_stmt:
             features.add(Feature.PRINT_STMT)
diff --git a/src/black/mode.py b/src/black/mode.py
--- a/src/black/mode.py
+++ b/src/black/mode.py
@@ -50,6 +50,7 @@ class Feature(Enum):
     RELAXED_DECORATORS = 10
     PATTERN_MATCHING = 11
     UNPACKING_ON_FLOW = 12
+    ANN_ASSIGN_EXTENDED_RHS = 13
     FORCE_OPTIONAL_PARENTHESES = 50
 
     # __future__ flags
@@ -118,6 +119,7 @@ class Feature(Enum):
         Feature.ASSIGNMENT_EXPRESSIONS,
         Feature.POS_ONLY_ARGUMENTS,
         Feature.UNPACKING_ON_FLOW,
+        Feature.ANN_ASSIGN_EXTENDED_RHS,
     },
     TargetVersion.PY39: {
         Feature.UNICODE_LITERALS,
@@ -131,6 +133,7 @@ class Feature(Enum):
         Feature.RELAXED_DECORATORS,
         Feature.POS_ONLY_ARGUMENTS,
         Feature.UNPACKING_ON_FLOW,
+        Feature.ANN_ASSIGN_EXTENDED_RHS,
     },
     TargetVersion.PY310: {
         Feature.UNICODE_LITERALS,
@@ -144,6 +147,7 @@ class Feature(Enum):
         Feature.RELAXED_DECORATORS,
         Feature.POS_ONLY_ARGUMENTS,
         Feature.UNPACKING_ON_FLOW,
+        Feature.ANN_ASSIGN_EXTENDED_RHS,
         Feature.PATTERN_MATCHING,
     },
 }


Test patch:
diff --git a/tests/test_black.py b/tests/test_black.py
--- a/tests/test_black.py
+++ b/tests/test_black.py
@@ -818,6 +818,18 @@ def test_get_features_used(self) -> None:
         self.assertEqual(black.get_features_used(node), {Feature.UNPACKING_ON_FLOW})
         node = black.lib2to3_parse("def fn(): return a, *b, c")
         self.assertEqual(black.get_features_used(node), {Feature.UNPACKING_ON_FLOW})
+        node = black.lib2to3_parse("x = a, *b, c")
+        self.assertEqual(black.get_features_used(node), set())
+        node = black.lib2to3_parse("x: Any = regular")
+        self.assertEqual(black.get_features_used(node), set())
+        node = black.lib2to3_parse("x: Any = (regular, regular)")
+        self.assertEqual(black.get_features_used(node), set())
+        node = black.lib2to3_parse("x: Any = Complex(Type(1))[something]")
+        self.assertEqual(black.get_features_used(node), set())
+        node = black.lib2to3_parse("x: Tuple[int, ...] = a, b, c")
+        self.assertEqual(
+            black.get_features_used(node), {Feature.ANN_ASSIGN_EXTENDED_RHS}
+        )
 
     def test_get_features_used_for_future_flags(self) -> None:
         for src, features in [