-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
378 additions
and
0 deletions.
There are no files selected for viewing
140 changes: 140 additions & 0 deletions
140
...f_python_formatter/tests/snapshots/black_compatibility@cases__context_managers_38.py.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
``` |
119 changes: 119 additions & 0 deletions
119
...rmatter/tests/snapshots/black_compatibility@cases__context_managers_autodetect_38.py.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
``` |
119 changes: 119 additions & 0 deletions
119
...tests/snapshots/black_compatibility@cases__preview_context_managers_autodetect_38.py.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
``` |