diff --git a/CHANGES.md b/CHANGES.md index e2cc70f1661..149ec8cb8c4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,6 +12,8 @@ - Fix formatting cells in IPython notebooks with magic methods and starting or trailing empty lines (#4484) +- Stop parenthesizing context managers on Python 3.9. Python 3.10+ is unaffected. + (#4488) ### Preview style diff --git a/src/black/mode.py b/src/black/mode.py index 02fe1de24db..83be106e02f 100644 --- a/src/black/mode.py +++ b/src/black/mode.py @@ -109,7 +109,6 @@ class Feature(Enum): Feature.POS_ONLY_ARGUMENTS, Feature.UNPACKING_ON_FLOW, Feature.ANN_ASSIGN_EXTENDED_RHS, - Feature.PARENTHESIZED_CONTEXT_MANAGERS, }, TargetVersion.PY310: { Feature.F_STRINGS, diff --git a/tests/data/cases/python39.py b/tests/data/cases/python39.py index 719c2b55745..56757fbea1a 100644 --- a/tests/data/cases/python39.py +++ b/tests/data/cases/python39.py @@ -10,6 +10,16 @@ def f(): def f(): ... +with long_context_manager_name1(), long_context_manager_name2(), long_context_manager_name3(): + ... + +with ( + long_context_manager_name1(), + long_context_manager_name2(), + long_context_manager_name3(), +): + ... + # output @relaxed_decorator[0] @@ -25,4 +35,15 @@ def f(): ... @extremely_long_variable_name_that_doesnt_fit := complex.expression( with_long="arguments_value_that_wont_fit_at_the_end_of_the_line" ) -def f(): ... \ No newline at end of file +def f(): ... + + +with long_context_manager_name1(), long_context_manager_name2(), long_context_manager_name3(): + ... + +with ( + long_context_manager_name1(), + long_context_manager_name2(), + long_context_manager_name3(), +): + ...