From 41b442698ab7099c9974c2e4a8d6bc9d2fb08070 Mon Sep 17 00:00:00 2001 From: takaya Date: Sun, 10 Nov 2024 20:56:41 +0900 Subject: [PATCH] add black compatibility snapshots --- ...ibility@cases__context_managers_38.py.snap | 140 ++++++++++++++++++ ...es__context_managers_autodetect_38.py.snap | 119 +++++++++++++++ ...iew_context_managers_autodetect_38.py.snap | 119 +++++++++++++++ 3 files changed, 378 insertions(+) create mode 100644 crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__context_managers_38.py.snap create mode 100644 crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__context_managers_autodetect_38.py.snap create mode 100644 crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_context_managers_autodetect_38.py.snap diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__context_managers_38.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__context_managers_38.py.snap new file mode 100644 index 00000000000000..9cb2a4d886f4db --- /dev/null +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__context_managers_38.py.snap @@ -0,0 +1,140 @@ +--- +source: crates/ruff_python_formatter/tests/fixtures.rs +input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/context_managers_38.py +snapshot_kind: text +--- +## Input + +```python +with \ + make_context_manager1() as cm1, \ + make_context_manager2() as cm2, \ + make_context_manager3() as cm3, \ + make_context_manager4() as cm4 \ +: + pass + + +with \ + make_context_manager1() as cm1, \ + make_context_manager2(), \ + make_context_manager3() as cm3, \ + make_context_manager4() \ +: + pass + + +with \ + new_new_new1() as cm1, \ + new_new_new2() \ +: + pass + + +with mock.patch.object( + self.my_runner, "first_method", autospec=True +) as mock_run_adb, mock.patch.object( + self.my_runner, "second_method", autospec=True, return_value="foo" +): + pass +``` + +## Black Differences + +```diff +--- Black ++++ Ruff +@@ -1,8 +1,18 @@ +-with make_context_manager1() as cm1, make_context_manager2() as cm2, make_context_manager3() as cm3, make_context_manager4() as cm4: ++with ( ++ make_context_manager1() as cm1, ++ make_context_manager2() as cm2, ++ make_context_manager3() as cm3, ++ make_context_manager4() as cm4, ++): + pass + + +-with make_context_manager1() as cm1, make_context_manager2(), make_context_manager3() as cm3, make_context_manager4(): ++with ( ++ make_context_manager1() as cm1, ++ make_context_manager2(), ++ make_context_manager3() as cm3, ++ make_context_manager4(), ++): + pass + + +@@ -10,9 +20,10 @@ + pass + + +-with mock.patch.object( +- self.my_runner, "first_method", autospec=True +-) as mock_run_adb, mock.patch.object( +- self.my_runner, "second_method", autospec=True, return_value="foo" ++with ( ++ mock.patch.object(self.my_runner, "first_method", autospec=True) as mock_run_adb, ++ mock.patch.object( ++ self.my_runner, "second_method", autospec=True, return_value="foo" ++ ), + ): + pass +``` + +## Ruff Output + +```python +with ( + make_context_manager1() as cm1, + make_context_manager2() as cm2, + make_context_manager3() as cm3, + make_context_manager4() as cm4, +): + pass + + +with ( + make_context_manager1() as cm1, + make_context_manager2(), + make_context_manager3() as cm3, + make_context_manager4(), +): + pass + + +with new_new_new1() as cm1, new_new_new2(): + pass + + +with ( + mock.patch.object(self.my_runner, "first_method", autospec=True) as mock_run_adb, + mock.patch.object( + self.my_runner, "second_method", autospec=True, return_value="foo" + ), +): + pass +``` + +## Black Output + +```python +with make_context_manager1() as cm1, make_context_manager2() as cm2, make_context_manager3() as cm3, make_context_manager4() as cm4: + pass + + +with make_context_manager1() as cm1, make_context_manager2(), make_context_manager3() as cm3, make_context_manager4(): + pass + + +with new_new_new1() as cm1, new_new_new2(): + pass + + +with mock.patch.object( + self.my_runner, "first_method", autospec=True +) as mock_run_adb, mock.patch.object( + self.my_runner, "second_method", autospec=True, return_value="foo" +): + pass +``` diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__context_managers_autodetect_38.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__context_managers_autodetect_38.py.snap new file mode 100644 index 00000000000000..ef447880124180 --- /dev/null +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__context_managers_autodetect_38.py.snap @@ -0,0 +1,119 @@ +--- +source: crates/ruff_python_formatter/tests/fixtures.rs +input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/context_managers_autodetect_38.py +snapshot_kind: text +--- +## Input + +```python +# This file doesn't use any Python 3.9+ only grammars. + + +# Make sure parens around a single context manager don't get autodetected as +# Python 3.9+. +with (a): + pass + + +with \ + make_context_manager1() as cm1, \ + make_context_manager2() as cm2, \ + make_context_manager3() as cm3, \ + make_context_manager4() as cm4 \ +: + pass + + +with mock.patch.object( + self.my_runner, "first_method", autospec=True +) as mock_run_adb, mock.patch.object( + self.my_runner, "second_method", autospec=True, return_value="foo" +): + pass +``` + +## Black Differences + +```diff +--- Black ++++ Ruff +@@ -7,13 +7,19 @@ + pass + + +-with make_context_manager1() as cm1, make_context_manager2() as cm2, make_context_manager3() as cm3, make_context_manager4() as cm4: ++with ( ++ make_context_manager1() as cm1, ++ make_context_manager2() as cm2, ++ make_context_manager3() as cm3, ++ make_context_manager4() as cm4, ++): + pass + + +-with mock.patch.object( +- self.my_runner, "first_method", autospec=True +-) as mock_run_adb, mock.patch.object( +- self.my_runner, "second_method", autospec=True, return_value="foo" ++with ( ++ mock.patch.object(self.my_runner, "first_method", autospec=True) as mock_run_adb, ++ mock.patch.object( ++ self.my_runner, "second_method", autospec=True, return_value="foo" ++ ), + ): + pass +``` + +## Ruff Output + +```python +# This file doesn't use any Python 3.9+ only grammars. + + +# Make sure parens around a single context manager don't get autodetected as +# Python 3.9+. +with a: + pass + + +with ( + make_context_manager1() as cm1, + make_context_manager2() as cm2, + make_context_manager3() as cm3, + make_context_manager4() as cm4, +): + pass + + +with ( + mock.patch.object(self.my_runner, "first_method", autospec=True) as mock_run_adb, + mock.patch.object( + self.my_runner, "second_method", autospec=True, return_value="foo" + ), +): + pass +``` + +## Black Output + +```python +# This file doesn't use any Python 3.9+ only grammars. + + +# Make sure parens around a single context manager don't get autodetected as +# Python 3.9+. +with a: + pass + + +with make_context_manager1() as cm1, make_context_manager2() as cm2, make_context_manager3() as cm3, make_context_manager4() as cm4: + pass + + +with mock.patch.object( + self.my_runner, "first_method", autospec=True +) as mock_run_adb, mock.patch.object( + self.my_runner, "second_method", autospec=True, return_value="foo" +): + pass +``` diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_context_managers_autodetect_38.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_context_managers_autodetect_38.py.snap new file mode 100644 index 00000000000000..591443294ac716 --- /dev/null +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_context_managers_autodetect_38.py.snap @@ -0,0 +1,119 @@ +--- +source: crates/ruff_python_formatter/tests/fixtures.rs +input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_38.py +snapshot_kind: text +--- +## Input + +```python +# This file doesn't use any Python 3.9+ only grammars. + + +# Make sure parens around a single context manager don't get autodetected as +# Python 3.9+. +with (a): + pass + + +with \ + make_context_manager1() as cm1, \ + make_context_manager2() as cm2, \ + make_context_manager3() as cm3, \ + make_context_manager4() as cm4 \ +: + pass + + +with mock.patch.object( + self.my_runner, "first_method", autospec=True +) as mock_run_adb, mock.patch.object( + self.my_runner, "second_method", autospec=True, return_value="foo" +): + pass +``` + +## Black Differences + +```diff +--- Black ++++ Ruff +@@ -7,13 +7,19 @@ + pass + + +-with make_context_manager1() as cm1, make_context_manager2() as cm2, make_context_manager3() as cm3, make_context_manager4() as cm4: ++with ( ++ make_context_manager1() as cm1, ++ make_context_manager2() as cm2, ++ make_context_manager3() as cm3, ++ make_context_manager4() as cm4, ++): + pass + + +-with mock.patch.object( +- self.my_runner, "first_method", autospec=True +-) as mock_run_adb, mock.patch.object( +- self.my_runner, "second_method", autospec=True, return_value="foo" ++with ( ++ mock.patch.object(self.my_runner, "first_method", autospec=True) as mock_run_adb, ++ mock.patch.object( ++ self.my_runner, "second_method", autospec=True, return_value="foo" ++ ), + ): + pass +``` + +## Ruff Output + +```python +# This file doesn't use any Python 3.9+ only grammars. + + +# Make sure parens around a single context manager don't get autodetected as +# Python 3.9+. +with a: + pass + + +with ( + make_context_manager1() as cm1, + make_context_manager2() as cm2, + make_context_manager3() as cm3, + make_context_manager4() as cm4, +): + pass + + +with ( + mock.patch.object(self.my_runner, "first_method", autospec=True) as mock_run_adb, + mock.patch.object( + self.my_runner, "second_method", autospec=True, return_value="foo" + ), +): + pass +``` + +## Black Output + +```python +# This file doesn't use any Python 3.9+ only grammars. + + +# Make sure parens around a single context manager don't get autodetected as +# Python 3.9+. +with a: + pass + + +with make_context_manager1() as cm1, make_context_manager2() as cm2, make_context_manager3() as cm3, make_context_manager4() as cm4: + pass + + +with mock.patch.object( + self.my_runner, "first_method", autospec=True +) as mock_run_adb, mock.patch.object( + self.my_runner, "second_method", autospec=True, return_value="foo" +): + pass +```