diff --git a/crates/ruff_linter/src/checkers/ast/mod.rs b/crates/ruff_linter/src/checkers/ast/mod.rs index c3acf77ce8fc8..f56966e6698ec 100644 --- a/crates/ruff_linter/src/checkers/ast/mod.rs +++ b/crates/ruff_linter/src/checkers/ast/mod.rs @@ -1415,7 +1415,7 @@ impl<'a> Checker<'a> { // subsequent nodes are evaluated in the inner scope. // // For example, given: - // ```py + // ```python // class A: // T = range(10) // @@ -1423,7 +1423,7 @@ impl<'a> Checker<'a> { // ``` // // Conceptually, this is compiled as: - // ```py + // ```python // class A: // T = range(10) // diff --git a/crates/ruff_linter/src/importer/insertion.rs b/crates/ruff_linter/src/importer/insertion.rs index 01b442dce5f19..4a2c782c18948 100644 --- a/crates/ruff_linter/src/importer/insertion.rs +++ b/crates/ruff_linter/src/importer/insertion.rs @@ -189,7 +189,7 @@ impl<'a> Insertion<'a> { Tok::NonLogicalNewline => {} Tok::Indent => { // This is like: - // ```py + // ```python // if True: // pass // ``` diff --git a/crates/ruff_linter/src/importer/mod.rs b/crates/ruff_linter/src/importer/mod.rs index 5241aa4f4c8d3..4624f12f688e0 100644 --- a/crates/ruff_linter/src/importer/mod.rs +++ b/crates/ruff_linter/src/importer/mod.rs @@ -209,7 +209,7 @@ impl<'a> Importer<'a> { // We also add a no-op edit to force conflicts with any other fixes that might try to // remove the import. Consider: // - // ```py + // ```python // import sys // // quit() diff --git a/crates/ruff_python_formatter/tests/fixtures.rs b/crates/ruff_python_formatter/tests/fixtures.rs index 604d79bbaee9f..7c11a1beb7ccc 100644 --- a/crates/ruff_python_formatter/tests/fixtures.rs +++ b/crates/ruff_python_formatter/tests/fixtures.rs @@ -71,7 +71,7 @@ fn black_compatibility() { // today. let mut snapshot = String::new(); write!(snapshot, "{}", Header::new("Input")).unwrap(); - write!(snapshot, "{}", CodeFrame::new("py", &content)).unwrap(); + write!(snapshot, "{}", CodeFrame::new("python", &content)).unwrap(); write!(snapshot, "{}", Header::new("Black Differences")).unwrap(); @@ -83,10 +83,10 @@ fn black_compatibility() { write!(snapshot, "{}", CodeFrame::new("diff", &diff)).unwrap(); write!(snapshot, "{}", Header::new("Ruff Output")).unwrap(); - write!(snapshot, "{}", CodeFrame::new("py", &formatted_code)).unwrap(); + write!(snapshot, "{}", CodeFrame::new("python", &formatted_code)).unwrap(); write!(snapshot, "{}", Header::new("Black Output")).unwrap(); - write!(snapshot, "{}", CodeFrame::new("py", &expected_output)).unwrap(); + write!(snapshot, "{}", CodeFrame::new("python", &expected_output)).unwrap(); insta::with_settings!({ omit_expression => true, @@ -113,7 +113,7 @@ fn format() { ensure_stability_when_formatting_twice(formatted_code, options.clone(), input_path); - let mut snapshot = format!("## Input\n{}", CodeFrame::new("py", &content)); + let mut snapshot = format!("## Input\n{}", CodeFrame::new("python", &content)); let options_path = input_path.with_extension("options.json"); if let Ok(options_file) = fs::File::open(options_path) { @@ -135,7 +135,7 @@ fn format() { "### Output {}\n{}{}", i + 1, CodeFrame::new("", &DisplayPyOptions(&options)), - CodeFrame::new("py", &formatted_code) + CodeFrame::new("python", &formatted_code) ) .unwrap(); } @@ -159,14 +159,19 @@ fn format() { ); if formatted == formatted_preview { - writeln!(snapshot, "## Output\n{}", CodeFrame::new("py", &formatted)).unwrap(); + writeln!( + snapshot, + "## Output\n{}", + CodeFrame::new("python", &formatted) + ) + .unwrap(); } else { // Having both snapshots makes it hard to see the difference, so we're keeping only // diff. writeln!( snapshot, "## Output\n{}\n## Preview changes\n{}", - CodeFrame::new("py", &formatted), + CodeFrame::new("python", &formatted), CodeFrame::new( "diff", TextDiff::from_lines(formatted, formatted_preview) diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@conditional_expression.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@conditional_expression.py.snap index f7012d70b5b76..8a1f4efdd8bb1 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@conditional_expression.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@conditional_expression.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/condition --- ## Input -```py +```python long_kwargs_single_line = my_function( foo="test, this is a sample value", bar=some_long_value_name_foo_bar_baz if some_boolean_variable else some_fallback_value_foo_bar_baz, @@ -149,7 +149,7 @@ def something(): ## Ruff Output -```py +```python long_kwargs_single_line = my_function( foo="test, this is a sample value", bar=some_long_value_name_foo_bar_baz @@ -238,7 +238,7 @@ def something(): ## Black Output -```py +```python long_kwargs_single_line = my_function( foo="test, this is a sample value", bar=( diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__blackd_diff.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__blackd_diff.py.snap index 835d6e4d60dc2..5a0a7e590e16a 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__blackd_diff.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__blackd_diff.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan --- ## Input -```py +```python def abc (): return ["hello", "world", "!"] @@ -33,7 +33,7 @@ print( "Incorrect formatting" ## Ruff Output -```py +```python def abc(): return ["hello", "world", "!"] @@ -43,7 +43,7 @@ print("Incorrect formatting") ## Black Output -```py +```python def abc (): return ["hello", "world", "!"] diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__debug_visitor.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__debug_visitor.py.snap index 5d7941640f647..36233a64ec31c 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__debug_visitor.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__debug_visitor.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan --- ## Input -```py +```python @dataclass class DebugVisitor(Visitor[T]): tree_depth: int = 0 @@ -79,7 +79,7 @@ class DebugVisitor(Visitor[T]): ## Ruff Output -```py +```python @dataclass class DebugVisitor(Visitor[T]): tree_depth: int = 0 @@ -116,7 +116,7 @@ class DebugVisitor(Visitor[T]): ## Black Output -```py +```python @dataclass class DebugVisitor(Visitor[T]): tree_depth: int = 0 diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__decorators.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__decorators.py.snap index 43d3d15edad27..9eaba761d4f44 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__decorators.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__decorators.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan --- ## Input -```py +```python # This file doesn't use the standard decomposition. # Decorator syntax test cases are separated by double # comments. # Those before the 'output' comment are valid under the old syntax. @@ -378,7 +378,7 @@ def f(): ## Ruff Output -```py +```python # This file doesn't use the standard decomposition. # Decorator syntax test cases are separated by double # comments. # Those before the 'output' comment are valid under the old syntax. @@ -589,7 +589,7 @@ def f(): ## Black Output -```py +```python ## @decorator()() diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__docstring_no_string_normalization.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__docstring_no_string_normalization.py.snap index 0b680fd94cdb0..bdc68fe77bcbb 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__docstring_no_string_normalization.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__docstring_no_string_normalization.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan --- ## Input -```py +```python class ALonelyClass: ''' A multiline class docstring. @@ -208,7 +208,7 @@ def multiline_backslash_3(): ## Ruff Output -```py +```python class ALonelyClass: """ A multiline class docstring. @@ -336,7 +336,7 @@ def multiline_backslash_3(): ## Black Output -```py +```python class ALonelyClass: ''' A multiline class docstring. diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__docstring_preview_no_string_normalization.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__docstring_preview_no_string_normalization.py.snap index 4503b0dd0052c..a2969f3e403b4 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__docstring_preview_no_string_normalization.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__docstring_preview_no_string_normalization.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan --- ## Input -```py +```python def do_not_touch_this_prefix(): R"""There was a bug where docstring prefixes would be normalized even with -S.""" @@ -37,7 +37,7 @@ def do_not_touch_this_prefix3(): ## Ruff Output -```py +```python def do_not_touch_this_prefix(): R"""There was a bug where docstring prefixes would be normalized even with -S.""" @@ -52,7 +52,7 @@ def do_not_touch_this_prefix3(): ## Black Output -```py +```python def do_not_touch_this_prefix(): R"""There was a bug where docstring prefixes would be normalized even with -S.""" diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__force_pyi.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__force_pyi.py.snap index 678606a9ed1b3..4eeadc7a82b9d 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__force_pyi.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__force_pyi.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan --- ## Input -```py +```python # flags: --pyi from typing import Union @@ -119,7 +119,7 @@ def eggs() -> Union[str, int]: ... ## Ruff Output -```py +```python # flags: --pyi from typing import Union @@ -183,7 +183,7 @@ def eggs() -> Union[str, int]: ## Black Output -```py +```python from typing import Union @bird diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__long_strings_flag_disabled.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__long_strings_flag_disabled.py.snap index 991b20198c79e..554b9b0fb365a 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__long_strings_flag_disabled.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__long_strings_flag_disabled.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan --- ## Input -```py +```python x = "This is a really long string that can't possibly be expected to fit all together on one line. In fact it may even take up three or more lines... like four or five... but probably just three." x += "This is a really long string that can't possibly be expected to fit all together on one line. In fact it may even take up three or more lines... like four or five... but probably just three." @@ -324,7 +324,7 @@ long_unmergable_string_with_pragma = ( ## Ruff Output -```py +```python x = "This is a really long string that can't possibly be expected to fit all together on one line. In fact it may even take up three or more lines... like four or five... but probably just three." x += "This is a really long string that can't possibly be expected to fit all together on one line. In fact it may even take up three or more lines... like four or five... but probably just three." @@ -617,7 +617,7 @@ long_unmergable_string_with_pragma = ( ## Black Output -```py +```python x = "This is a really long string that can't possibly be expected to fit all together on one line. In fact it may even take up three or more lines... like four or five... but probably just three." x += "This is a really long string that can't possibly be expected to fit all together on one line. In fact it may even take up three or more lines... like four or five... but probably just three." diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__power_op_newline.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__power_op_newline.py.snap index 991e030ac9eb1..b9ff9703eb179 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__power_op_newline.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__power_op_newline.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan --- ## Input -```py +```python importA;()<<0**0# ``` @@ -25,14 +25,14 @@ importA;()<<0**0# ## Ruff Output -```py +```python importA () << 0**0 # ``` ## Black Output -```py +```python importA ( () diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__string_quotes.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__string_quotes.py.snap index 4600e1fd20261..41d92b73c6b58 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__string_quotes.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__string_quotes.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan --- ## Input -```py +```python '''''' '\'' @@ -88,7 +88,7 @@ f"\"{a}\"{'hello' * b}\"{c}\"" ## Ruff Output -```py +```python """""" "'" @@ -151,7 +151,7 @@ f"\"{a}\"{'hello' * b}\"{c}\"" ## Black Output -```py +```python """""" "'" diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@py_310__pattern_matching_extras.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@py_310__pattern_matching_extras.py.snap index 3f7ef28e907cb..865bb18e4453a 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@py_310__pattern_matching_extras.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@py_310__pattern_matching_extras.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/py_310/pa --- ## Input -```py +```python import match match something: @@ -162,7 +162,7 @@ match bar1: ## Ruff Output -```py +```python import match match something: @@ -295,7 +295,7 @@ match bar1: ## Black Output -```py +```python import match match something: diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@py_310__pattern_matching_style.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@py_310__pattern_matching_style.py.snap index b73b0f87fa351..51669107f8a53 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@py_310__pattern_matching_style.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@py_310__pattern_matching_style.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/py_310/pa --- ## Input -```py +```python match something: case b(): print(1+1) case c( @@ -99,7 +99,7 @@ match match( ## Ruff Output -```py +```python match something: case b(): print(1 + 1) @@ -145,7 +145,7 @@ match match(): ## Black Output -```py +```python match something: case b(): print(1 + 1) diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@py_310__pep_572_py310.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@py_310__pep_572_py310.py.snap index b8d306b641282..b694f46cfdfaa 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@py_310__pep_572_py310.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@py_310__pep_572_py310.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/py_310/pe --- ## Input -```py +```python # Unparenthesized walruses are now allowed in indices since Python 3.10. x[a:=0] x[a:=0, b:=1] @@ -42,7 +42,7 @@ f(x, (a := b + c for c in range(10)), y=z, **q) ## Ruff Output -```py +```python # Unparenthesized walruses are now allowed in indices since Python 3.10. x[a := 0] x[a := 0, b := 1] @@ -62,7 +62,7 @@ f(x, (a := b + c for c in range(10)), y=z, **q) ## Black Output -```py +```python # Unparenthesized walruses are now allowed in indices since Python 3.10. x[a:=0] x[a:=0, b:=1] diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@py_38__pep_572_remove_parens.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@py_38__pep_572_remove_parens.py.snap index daea36ba7ec65..49c78e65597e9 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@py_38__pep_572_remove_parens.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@py_38__pep_572_remove_parens.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/py_38/pep --- ## Input -```py +```python if (foo := 0): pass @@ -94,7 +94,7 @@ async def await_the_walrus(): ## Ruff Output -```py +```python if foo := 0: pass @@ -170,7 +170,7 @@ async def await_the_walrus(): ## Black Output -```py +```python if foo := 0: pass diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@raw_docstring.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@raw_docstring.py.snap index 8177e7d37f13b..25946da099349 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@raw_docstring.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@raw_docstring.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/raw_docst --- ## Input -```py +```python # flags: --preview --skip-string-normalization class C: @@ -50,7 +50,7 @@ class UpperCaseR: ## Ruff Output -```py +```python # flags: --preview --skip-string-normalization class C: @@ -72,7 +72,7 @@ class UpperCaseR: ## Black Output -```py +```python class C: r"""Raw""" diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__comment_after_escaped_newline.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__comment_after_escaped_newline.py.snap index 5a209c575958b..9656ed1e16fe5 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__comment_after_escaped_newline.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__comment_after_escaped_newline.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python def bob(): \ # pylint: disable=W9016 pass @@ -36,7 +36,7 @@ def bobtwo(): \ ## Ruff Output -```py +```python def bob(): # pylint: disable=W9016 pass @@ -49,7 +49,7 @@ def bobtwo(): ## Black Output -```py +```python def bob(): # pylint: disable=W9016 pass diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__comments2.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__comments2.py.snap index 0e98a11642d25..9c0622bce3e52 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__comments2.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__comments2.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import ( MyLovelyCompanyTeamProjectComponent # NOT DRY ) @@ -246,7 +246,7 @@ instruction()#comment with bad spacing ## Ruff Output -```py +```python from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import ( MyLovelyCompanyTeamProjectComponent, # NOT DRY ) @@ -442,7 +442,7 @@ instruction() # comment with bad spacing ## Black Output -```py +```python from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import ( MyLovelyCompanyTeamProjectComponent, # NOT DRY ) diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__comments6.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__comments6.py.snap index 6725d8d840c1f..45ab60a21a43b 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__comments6.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__comments6.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python from typing import Any, Tuple @@ -181,7 +181,7 @@ aaaaaaaaaaaaa, bbbbbbbbb = map(list, map(itertools.chain.from_iterable, zip(*ite ## Ruff Output -```py +```python from typing import Any, Tuple @@ -315,7 +315,7 @@ aaaaaaaaaaaaa, bbbbbbbbb = map(list, map(itertools.chain.from_iterable, zip(*ite ## Black Output -```py +```python from typing import Any, Tuple diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__comments9.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__comments9.py.snap index ede65b69510af..743906edda155 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__comments9.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__comments9.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python # Test for https://github.com/psf/black/issues/246. some = statement @@ -179,7 +179,7 @@ def bar(): ## Ruff Output -```py +```python # Test for https://github.com/psf/black/issues/246. some = statement @@ -342,7 +342,7 @@ def bar(): ## Black Output -```py +```python # Test for https://github.com/psf/black/issues/246. some = statement diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__composition.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__composition.py.snap index fbda66e07b2ff..756ef81dd3b62 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__composition.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__composition.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python class C: def test(self) -> None: with patch("black.out", print): @@ -242,7 +242,7 @@ class C: ## Ruff Output -```py +```python class C: def test(self) -> None: with patch("black.out", print): @@ -427,7 +427,7 @@ class C: ## Black Output -```py +```python class C: def test(self) -> None: with patch("black.out", print): diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__composition_no_trailing_comma.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__composition_no_trailing_comma.py.snap index 06bcb6b4e7d22..89664dc7c155b 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__composition_no_trailing_comma.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__composition_no_trailing_comma.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python class C: def test(self) -> None: with patch("black.out", print): @@ -242,7 +242,7 @@ class C: ## Ruff Output -```py +```python class C: def test(self) -> None: with patch("black.out", print): @@ -427,7 +427,7 @@ class C: ## Black Output -```py +```python class C: def test(self) -> None: with patch("black.out", print): diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__docstring_preview.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__docstring_preview.py.snap index dad30c4cb8fef..afb73efb11279 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__docstring_preview.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__docstring_preview.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python def docstring_almost_at_line_limit(): """long docstring................................................................. """ @@ -76,7 +76,7 @@ def single_quote_docstring_over_line_limit2(): ## Ruff Output -```py +```python def docstring_almost_at_line_limit(): """long docstring.................................................................""" @@ -130,7 +130,7 @@ def single_quote_docstring_over_line_limit2(): ## Black Output -```py +```python def docstring_almost_at_line_limit(): """long docstring.................................................................""" diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__expression.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__expression.py.snap index 02a6a4a76c98a..ea14186d298f3 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__expression.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__expression.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python ... 'some_string' b'\\xa3' @@ -279,7 +279,7 @@ last_call() ## Ruff Output -```py +```python ... "some_string" b"\\xa3" @@ -655,7 +655,7 @@ last_call() ## Black Output -```py +```python ... "some_string" b"\\xa3" diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtonoff.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtonoff.py.snap index ce417c728b56b..2df0b531f8ef7 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtonoff.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtonoff.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python #!/usr/bin/env python3 import asyncio import sys @@ -271,7 +271,7 @@ d={'a':1, ## Ruff Output -```py +```python #!/usr/bin/env python3 import asyncio import sys @@ -506,7 +506,7 @@ d={'a':1, ## Black Output -```py +```python #!/usr/bin/env python3 import asyncio import sys diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtonoff4.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtonoff4.py.snap index 5962f31f5f7b4..529e50d32cbd2 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtonoff4.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtonoff4.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python # fmt: off @test([ 1, 2, @@ -53,7 +53,7 @@ def f(): pass ## Ruff Output -```py +```python # fmt: off @test([ 1, 2, @@ -71,7 +71,7 @@ def f(): pass ## Black Output -```py +```python # fmt: off @test([ 1, 2, diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtonoff5.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtonoff5.py.snap index a3b86b9e60992..a531a87c052d4 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtonoff5.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtonoff5.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python # Regression test for https://github.com/psf/black/issues/3129. setup( entry_points={ @@ -122,7 +122,7 @@ elif unformatted: ## Ruff Output -```py +```python # Regression test for https://github.com/psf/black/issues/3129. setup( entry_points={ @@ -213,7 +213,7 @@ elif unformatted: ## Black Output -```py +```python # Regression test for https://github.com/psf/black/issues/3129. setup( entry_points={ diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtpass_imports.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtpass_imports.py.snap index 7d2474337a770..8dceca43bc0d5 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtpass_imports.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtpass_imports.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python # Regression test for https://github.com/psf/black/issues/3438 import ast @@ -43,7 +43,7 @@ import zoneinfo ## Ruff Output -```py +```python # Regression test for https://github.com/psf/black/issues/3438 import ast @@ -68,7 +68,7 @@ import zoneinfo ## Black Output -```py +```python # Regression test for https://github.com/psf/black/issues/3438 import ast diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtskip5.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtskip5.py.snap index 58985692cd6bd..597ccdeeba38a 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtskip5.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtskip5.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python a, b, c = 3, 4, 5 if ( a == 3 @@ -34,7 +34,7 @@ else: ## Ruff Output -```py +```python a, b, c = 3, 4, 5 if ( a == 3 @@ -48,7 +48,7 @@ else: ## Black Output -```py +```python a, b, c = 3, 4, 5 if ( a == 3 diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__function.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__function.py.snap index dacb0b6cac47d..317d6c6a188b6 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__function.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__function.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python #!/usr/bin/env python3 import asyncio import sys @@ -119,7 +119,7 @@ def __await__(): return (yield) ## Ruff Output -```py +```python #!/usr/bin/env python3 import asyncio import sys @@ -273,7 +273,7 @@ def __await__(): ## Black Output -```py +```python #!/usr/bin/env python3 import asyncio import sys diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__function2.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__function2.py.snap index 2d1ed7c6ad0d6..2fc0696b9ba42 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__function2.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__function2.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python def f( a, **kwargs, @@ -85,7 +85,7 @@ with hmm_but_this_should_get_two_preceding_newlines(): ## Ruff Output -```py +```python def f( a, **kwargs, @@ -153,7 +153,7 @@ with hmm_but_this_should_get_two_preceding_newlines(): ## Black Output -```py +```python def f( a, **kwargs, diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__ignore_pyi.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__ignore_pyi.py.snap index d12ec42a82ba5..9027c47633afd 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__ignore_pyi.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__ignore_pyi.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python def f(): # type: ignore ... @@ -64,7 +64,7 @@ def h(): ## Ruff Output -```py +```python def f(): # type: ignore ... @@ -94,7 +94,7 @@ def h(): ## Black Output -```py +```python def f(): # type: ignore ... diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__multiline_consecutive_open_parentheses_ignore.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__multiline_consecutive_open_parentheses_ignore.py.snap index 7759ca34bcda6..66ce78e5b1d94 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__multiline_consecutive_open_parentheses_ignore.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__multiline_consecutive_open_parentheses_ignore.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python # This is a regression test. Issue #3737 a = ( # type: ignore @@ -48,7 +48,7 @@ print( "111" ) # type: ignore ## Ruff Output -```py +```python # This is a regression test. Issue #3737 a = ( # type: ignore @@ -70,7 +70,7 @@ print("111") # type: ignore ## Black Output -```py +```python # This is a regression test. Issue #3737 a = ( # type: ignore diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__remove_await_parens.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__remove_await_parens.py.snap index 428ca61376081..a72df1daba4cf 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__remove_await_parens.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__remove_await_parens.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python import asyncio # Control example @@ -108,7 +108,7 @@ async def main(): ## Ruff Output -```py +```python import asyncio @@ -208,7 +208,7 @@ async def main(): ## Black Output -```py +```python import asyncio diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__remove_except_parens.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__remove_except_parens.py.snap index 1b9f9e5d08948..a0459420e5ce4 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__remove_except_parens.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__remove_except_parens.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python # These brackets are redundant, therefore remove. try: a.something @@ -62,7 +62,7 @@ except (some.really.really.really.looooooooooooooooooooooooooooooooong.module.ov ## Ruff Output -```py +```python # These brackets are redundant, therefore remove. try: a.something @@ -107,7 +107,7 @@ except ( ## Black Output -```py +```python # These brackets are redundant, therefore remove. try: a.something diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__remove_for_brackets.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__remove_for_brackets.py.snap index 9a32084e95cd9..3c2eb7eab684e 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__remove_for_brackets.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__remove_for_brackets.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python # Only remove tuple brackets after `for` for (k, v) in d.items(): print(k, v) @@ -46,7 +46,7 @@ for (((((k, v))))) in d.items(): ## Ruff Output -```py +```python # Only remove tuple brackets after `for` for k, v in d.items(): print(k, v) @@ -76,7 +76,7 @@ for k, v in d.items(): ## Black Output -```py +```python # Only remove tuple brackets after `for` for k, v in d.items(): print(k, v) diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__return_annotation_brackets.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__return_annotation_brackets.py.snap index 552ca4576bfc3..fd67777f13055 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__return_annotation_brackets.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__return_annotation_brackets.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python # Control def double(a: int) -> int: return 2*a @@ -126,7 +126,7 @@ def foo() -> tuple[int, int, int,]: ## Ruff Output -```py +```python # Control def double(a: int) -> int: return 2 * a @@ -259,7 +259,7 @@ def foo() -> ( ## Black Output -```py +```python # Control def double(a: int) -> int: return 2 * a diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__torture.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__torture.py.snap index f44e1053f0b4b..6b7ddaa378e9e 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__torture.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__torture.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python importA;() << 0 ** 101234234242352525425252352352525234890264906820496920680926538059059209922523523525 # assert sort_by_dependency( @@ -66,7 +66,7 @@ assert ( ## Ruff Output -```py +```python importA ( () @@ -129,7 +129,7 @@ assert a_function( ## Black Output -```py +```python importA ( () diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__trailing_commas_in_leading_parts.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__trailing_commas_in_leading_parts.py.snap index 514ea6258ad1e..8ad0695b0401c 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__trailing_commas_in_leading_parts.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__trailing_commas_in_leading_parts.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python zero(one,).two(three,).four(five,) func1(arg1).func2(arg2,).func3(arg3).func4(arg4,).func5(arg5) @@ -72,7 +72,7 @@ assert xxxxxxxxx.xxxxxxxxx.xxxxxxxxx( ## Ruff Output -```py +```python zero( one, ).two( @@ -123,7 +123,7 @@ assert ( ## Black Output -```py +```python zero( one, ).two( diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__tupleassign.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__tupleassign.py.snap index d2bc4735aeb8e..16f034ed48ce3 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__tupleassign.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__tupleassign.py.snap @@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca --- ## Input -```py +```python # This is a standalone comment. sdfjklsdfsjldkflkjsf, sdfjsdfjlksdljkfsdlkf, sdfsdjfklsdfjlksdljkf, sdsfsdfjskdflsfsdf = 1, 2, 3 @@ -32,7 +32,7 @@ this_will_be_wrapped_in_parens, = struct.unpack(b"12345678901234567890") ## Ruff Output -```py +```python # This is a standalone comment. ( sdfjklsdfsjldkflkjsf, @@ -49,7 +49,7 @@ this_will_be_wrapped_in_parens, = struct.unpack(b"12345678901234567890") ## Black Output -```py +```python # This is a standalone comment. ( sdfjklsdfsjldkflkjsf, diff --git a/crates/ruff_python_formatter/tests/snapshots/format@carriage_return__string.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@carriage_return__string.py.snap index 522538378af1f..97df9f7e82e15 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@carriage_return__string.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@carriage_return__string.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/carriage_return/string.py --- ## Input -```py +```python 'This string will not include \ backslashes or newline characters.' @@ -13,7 +13,7 @@ String \" ``` ## Output -```py +```python "This string will not include \ backslashes or newline characters." diff --git a/crates/ruff_python_formatter/tests/snapshots/format@docstring.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@docstring.py.snap index dc942c632079c..4e92b7c09db29 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@docstring.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@docstring.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring.py --- ## Input -```py +```python def single_line_backslashes1(): """ content\ """ return @@ -169,7 +169,7 @@ magic-trailing-comma = Respect preview = Disabled ``` -```py +```python def single_line_backslashes1(): """content\ """ return @@ -335,7 +335,7 @@ magic-trailing-comma = Respect preview = Disabled ``` -```py +```python def single_line_backslashes1(): """content\ """ return @@ -501,7 +501,7 @@ magic-trailing-comma = Respect preview = Disabled ``` -```py +```python def single_line_backslashes1(): """content\ """ return @@ -667,7 +667,7 @@ magic-trailing-comma = Respect preview = Disabled ``` -```py +```python def single_line_backslashes1(): """content\ """ return diff --git a/crates/ruff_python_formatter/tests/snapshots/format@empty_multiple_trailing_newlines.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@empty_multiple_trailing_newlines.py.snap index acae2f4cc3f52..5582da34d901e 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@empty_multiple_trailing_newlines.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@empty_multiple_trailing_newlines.py.snap @@ -3,14 +3,14 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/empty_multiple_trailing_newlines.py --- ## Input -```py +```python ``` ## Output -```py +```python ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@empty_now_newline.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@empty_now_newline.py.snap index 77fbee7d919c7..cc9ebfcc7e754 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@empty_now_newline.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@empty_now_newline.py.snap @@ -3,11 +3,11 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/empty_now_newline.py --- ## Input -```py +```python ``` ## Output -```py +```python ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@empty_trailing_newline.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@empty_trailing_newline.py.snap index a89a4db2c6866..516325c9df299 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@empty_trailing_newline.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@empty_trailing_newline.py.snap @@ -3,12 +3,12 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/empty_trailing_newline.py --- ## Input -```py +```python ``` ## Output -```py +```python ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@empty_whitespace.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@empty_whitespace.py.snap index 33604dc12f621..48184db5a3257 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@empty_whitespace.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@empty_whitespace.py.snap @@ -3,11 +3,11 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/empty_whitespace.py --- ## Input -```py +```python ``` ## Output -```py +```python ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__annotated_assign.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__annotated_assign.py.snap index 55c646d9fddad..0ce76c87517d4 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__annotated_assign.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__annotated_assign.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/annotated_assign.py --- ## Input -```py +```python a: string b: string = "test" @@ -20,7 +20,7 @@ b: list[ ``` ## Output -```py +```python a: string b: string = "test" diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__attribute.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__attribute.py.snap index 0e4951e92a9d6..bbcc0efd95af9 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__attribute.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__attribute.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/attribute.py --- ## Input -```py +```python from argparse import Namespace a = Namespace() @@ -161,7 +161,7 @@ result = ( ``` ## Output -```py +```python from argparse import Namespace a = Namespace() diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__await.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__await.py.snap index f01cb0d85f11f..fa8d86bf521f5 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__await.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__await.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/await.py --- ## Input -```py +```python # Regression test for: https://github.com/astral-sh/ruff/issues/7420 result = await self.request( f"/applications/{int(application_id)}/guilds/{int(scope)}/commands/{int(command_id)}/permissions" @@ -57,7 +57,7 @@ await ( ``` ## Output -```py +```python # Regression test for: https://github.com/astral-sh/ruff/issues/7420 result = await self.request( f"/applications/{int(application_id)}/guilds/{int(scope)}/commands/{int(command_id)}/permissions" diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__binary.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__binary.py.snap index eb9f911a4ed93..e245378863ad4 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__binary.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__binary.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/binary.py --- ## Input -```py +```python (aaaaaaaa + # trailing operator comment b # trailing right comment @@ -415,7 +415,7 @@ if True: ``` ## Output -```py +```python ( aaaaaaaa + # trailing operator comment diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__binary_implicit_string.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__binary_implicit_string.py.snap index 286353d24f644..5f3c84a8dfa69 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__binary_implicit_string.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__binary_implicit_string.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/binary_implicit_string.py --- ## Input -```py +```python raise ImproperlyConfigured( "The app module %r has multiple filesystem locations (%r); " @@ -198,7 +198,7 @@ class EC2REPATH: ``` ## Output -```py +```python raise ImproperlyConfigured( "The app module %r has multiple filesystem locations (%r); " "you must configure this app with an AppConfig subclass " diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__binary_pow_spacing.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__binary_pow_spacing.py.snap index c22840f9f2ec4..f54dfeb51cfd8 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__binary_pow_spacing.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__binary_pow_spacing.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/binary_pow_spacing.py --- ## Input -```py +```python # No spacing 5 ** 5 5.0 ** 5.0 @@ -17,7 +17,7 @@ None ** None ``` ## Output -```py +```python # No spacing 5**5 5.0**5.0 diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__boolean_operation.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__boolean_operation.py.snap index 819040b366b7a..74c03816e94ba 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__boolean_operation.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__boolean_operation.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/boolean_operation.py --- ## Input -```py +```python if ( self._proc # has the child process finished? @@ -194,7 +194,7 @@ if (self._proc ``` ## Output -```py +```python if ( self._proc # has the child process finished? diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__bytes.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__bytes.py.snap index 158e4f65c6d13..1e8baabd73238 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__bytes.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__bytes.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/bytes.py --- ## Input -```py +```python b"' test" b'" test' @@ -137,7 +137,7 @@ magic-trailing-comma = Respect preview = Disabled ``` -```py +```python b"' test" b'" test' @@ -286,7 +286,7 @@ magic-trailing-comma = Respect preview = Disabled ``` -```py +```python b"' test" b'" test' diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__call.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__call.py.snap index 861c4f0553512..1b35bce81b919 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__call.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__call.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/call.py --- ## Input -```py +```python from unittest.mock import MagicMock @@ -282,7 +282,7 @@ result = (object[complicate_caller])("argument").a["b"].test(argument) ``` ## Output -```py +```python from unittest.mock import MagicMock diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__compare.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__compare.py.snap index 6498068ee8afc..314a53513b8ba 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__compare.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__compare.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/compare.py --- ## Input -```py +```python a == b a != b a < b @@ -187,7 +187,7 @@ c = (a * ``` ## Output -```py +```python a == b a != b a < b diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__dict.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__dict.py.snap index 3745b5bdcecc7..6ecda476dd956 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__dict.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__dict.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/dict.py --- ## Input -```py +```python # before { # open key# key @@ -141,7 +141,7 @@ query = { ``` ## Output -```py +```python # before { # open key: # key diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__dict_comp.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__dict_comp.py.snap index df00b778e8905..56181cd10a05d 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__dict_comp.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__dict_comp.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/dict_comp.py --- ## Input -```py +```python {i: i for i in []} {i: i for i in [1,]} @@ -186,7 +186,7 @@ query = { ``` ## Output -```py +```python {i: i for i in []} { diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring.py.snap index 5d39862c2d571..d9bc028763812 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring.py --- ## Input -```py +```python ( f'{one}' f'{two}' @@ -71,7 +71,7 @@ z = f'''a{""}b''' f'''c{1}d"""e''' ``` ## Output -```py +```python (f"{one}" f"{two}") diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__generator_exp.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__generator_exp.py.snap index bce2611ab0621..4818acca87919 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__generator_exp.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__generator_exp.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/generator_exp.py --- ## Input -```py +```python (a for b in c) # parens around generator expression not required @@ -78,7 +78,7 @@ tuple( ``` ## Output -```py +```python (a for b in c) # parens around generator expression not required diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__if.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__if.py.snap index 7aa5a080c8298..e73a5515f3771 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__if.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__if.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/if.py --- ## Input -```py +```python a1 = 1 if True else 2 a2 = "this is a very long text that will make the group break to check that parentheses are added" if True else 2 @@ -117,7 +117,7 @@ def something(): ``` ## Output -```py +```python a1 = 1 if True else 2 a2 = ( diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__lambda.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__lambda.py.snap index 241f61a481c03..e9874be9def3d 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__lambda.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__lambda.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/lambda.py --- ## Input -```py +```python # Leading lambda x: x # Trailing # Trailing @@ -237,7 +237,7 @@ def a(): ``` ## Output -```py +```python # Leading lambda x: x # Trailing # Trailing diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__list.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__list.py.snap index 1d00f6ae54102..b798984c65a8e 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__list.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__list.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/list.py --- ## Input -```py +```python # Dangling comment placement in empty lists # Regression test for https://github.com/python/cpython/blob/03160630319ca26dcbbad65225da4248e54c45ec/Tools/c-analyzer/c_analyzer/datafiles.py#L14-L16 a1 = [ # a @@ -67,7 +67,7 @@ c1 = [ # trailing open bracket ``` ## Output -```py +```python # Dangling comment placement in empty lists # Regression test for https://github.com/python/cpython/blob/03160630319ca26dcbbad65225da4248e54c45ec/Tools/c-analyzer/c_analyzer/datafiles.py#L14-L16 a1 = [ # a diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__list_comp.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__list_comp.py.snap index a7007f72e44b1..316630a83f9d4 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__list_comp.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__list_comp.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/list_comp.py --- ## Input -```py +```python [i for i in []] [i for i in [1,]] @@ -114,7 +114,7 @@ aaaaaaaaaaaaaaaaaaaaa = [ ``` ## Output -```py +```python [i for i in []] [ diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__named_expr.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__named_expr.py.snap index 68a74972a050d..8221398aa9a5c 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__named_expr.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__named_expr.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/named_expr.py --- ## Input -```py +```python y = 1 if ( @@ -106,7 +106,7 @@ async def f(): ``` ## Output -```py +```python y = 1 if ( diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__number.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__number.py.snap index feea8103e080f..fe8a33ef8e8e0 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__number.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__number.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/number.py --- ## Input -```py +```python .1 1. 1E+1 @@ -14,7 +14,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression ``` ## Output -```py +```python 0.1 1.0 1e1 diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__optional_parentheses_comments.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__optional_parentheses_comments.py.snap index 1cf74fe785ea2..4279cd03f29db 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__optional_parentheses_comments.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__optional_parentheses_comments.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/optional_parentheses_comments.py --- ## Input -```py +```python comment_string = "Long lines with inline comments should have their comments appended to the reformatted string's enclosing right parentheses." # This comment gets thrown to the top. # 88 characters unparenthesized @@ -213,7 +213,7 @@ def test6(): ``` ## Output -```py +```python comment_string = "Long lines with inline comments should have their comments appended to the reformatted string's enclosing right parentheses." # This comment gets thrown to the top. # 88 characters unparenthesized diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__set_comp.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__set_comp.py.snap index 4244dd131853d..b73d9a599e793 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__set_comp.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__set_comp.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/set_comp.py --- ## Input -```py +```python {i for i in []} {i for i in [1,]} @@ -62,7 +62,7 @@ selected_choices = { ``` ## Output -```py +```python {i for i in []} { diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__slice.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__slice.py.snap index 9ba98aaef7f79..306346667803d 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__slice.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__slice.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/slice.py --- ## Input -```py +```python # Handle comments both when lower and upper exist and when they don't a1 = "a"[ # a @@ -119,7 +119,7 @@ self.assertEqual( ``` ## Output -```py +```python # Handle comments both when lower and upper exist and when they don't a1 = "a"[ # a diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__split_empty_brackets.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__split_empty_brackets.py.snap index c923784d048e3..810964acc19a2 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__split_empty_brackets.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__split_empty_brackets.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/split_empty_brackets.py --- ## Input -```py +```python # Expressions with empty parentheses. ct_match = ( unicodedata.normalize("NFKC", s1).casefold() @@ -97,7 +97,7 @@ response = await sync_to_async( ``` ## Output -```py +```python # Expressions with empty parentheses. ct_match = ( unicodedata.normalize("NFKC", s1).casefold() diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__starred.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__starred.py.snap index 2393ae56af7a1..225242f0342fc 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__starred.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__starred.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/starred.py --- ## Input -```py +```python call( # Leading starred comment * # Trailing star comment @@ -40,7 +40,7 @@ call( ``` ## Output -```py +```python call( # Leading starred comment # Trailing star comment diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__string.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__string.py.snap index 28ebcfd8502dc..09830dae06dfa 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__string.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__string.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/string.py --- ## Input -```py +```python "' test" '" test' @@ -152,7 +152,7 @@ magic-trailing-comma = Respect preview = Disabled ``` -```py +```python "' test" '" test' @@ -325,7 +325,7 @@ magic-trailing-comma = Respect preview = Disabled ``` -```py +```python "' test" '" test' diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__subscript.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__subscript.py.snap index 102175f3d5d81..35f5f5e92994f 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__subscript.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__subscript.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/subscript.py --- ## Input -```py +```python # Regression test for: https://github.com/astral-sh/ruff/issues/7370 result = ( f(111111111111111111111111111111111111111111111111111111111111111111111111111111111) @@ -12,7 +12,7 @@ result = ( ``` ## Output -```py +```python # Regression test for: https://github.com/astral-sh/ruff/issues/7370 result = ( f(111111111111111111111111111111111111111111111111111111111111111111111111111111111) diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__tuple.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__tuple.py.snap index 0f8997294a341..1aa67094d507f 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__tuple.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__tuple.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/tuple.py --- ## Input -```py +```python # Non-wrapping parentheses checks a1 = 1, 2 a2 = (1, 2) @@ -78,7 +78,7 @@ i1 = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ``` ## Output -```py +```python # Non-wrapping parentheses checks a1 = 1, 2 a2 = (1, 2) diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__unary.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__unary.py.snap index 6146fd82d5424..0d80fc1a258b6 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__unary.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__unary.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/unary.py --- ## Input -```py +```python if not aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb: pass @@ -202,7 +202,7 @@ def foo(): ``` ## Output -```py +```python if ( not aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__unsplittable.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__unsplittable.py.snap index 95ec4e212e810..a40713b2d1f4c 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__unsplittable.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__unsplittable.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/unsplittable.py --- ## Input -```py +```python x = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa x_aa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa @@ -103,7 +103,7 @@ def f(): ``` ## Output -```py +```python x = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa x_aa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__yield.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__yield.py.snap index 463ed0d1eccef..0d591cc737f80 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__yield.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__yield.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/yield.py --- ## Input -```py +```python l = [1,2,3,4] def foo(): @@ -128,7 +128,7 @@ print((yield x)) ``` ## Output -```py +```python l = [1, 2, 3, 4] diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__yield_from.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__yield_from.py.snap index 3439eafe704cb..cfbea8ba9aab5 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__yield_from.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__yield_from.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/yield_from.py --- ## Input -```py +```python l = [1,2,3,4] @@ -42,7 +42,7 @@ def foo(): ``` ## Output -```py +```python l = [1, 2, 3, 4] diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__comments.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__comments.py.snap index ad353b6d2f239..a84753bdf6ecf 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__comments.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__comments.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/comments.py --- ## Input -```py +```python pass # fmt: off @@ -35,7 +35,7 @@ def test(): ``` ## Output -```py +```python pass # fmt: off diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__empty_file.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__empty_file.py.snap index 7dbe39d5d1abe..ea604491f3237 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__empty_file.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__empty_file.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/empty_file.py --- ## Input -```py +```python # fmt: off # this does not work because there are no statements @@ -12,7 +12,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off ``` ## Output -```py +```python # fmt: off # this does not work because there are no statements diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__fmt_off_docstring.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__fmt_off_docstring.py.snap index 2315411c172d3..8cca1bee8815a 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__fmt_off_docstring.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__fmt_off_docstring.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/fmt_off_docstring.py --- ## Input -```py +```python def test(): # fmt: off """ This docstring does not @@ -36,7 +36,7 @@ magic-trailing-comma = Respect preview = Disabled ``` -```py +```python def test(): # fmt: off """ This docstring does not @@ -69,7 +69,7 @@ magic-trailing-comma = Respect preview = Disabled ``` -```py +```python def test(): # fmt: off """ This docstring does not diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__fmt_off_unclosed_deep_nested_trailing_comment.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__fmt_off_unclosed_deep_nested_trailing_comment.py.snap index 081eb523828fd..474830dfe139b 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__fmt_off_unclosed_deep_nested_trailing_comment.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__fmt_off_unclosed_deep_nested_trailing_comment.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/fmt_off_unclosed_deep_nested_trailing_comment.py --- ## Input -```py +```python # Regression test for https://github.com/astral-sh/ruff/issues/8211 # fmt: off @@ -15,7 +15,7 @@ if True: ``` ## Output -```py +```python # Regression test for https://github.com/astral-sh/ruff/issues/8211 # fmt: off diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__fmt_off_unclosed_trailing_comment.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__fmt_off_unclosed_trailing_comment.py.snap index 14cf588e95ccb..2fb64fea20688 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__fmt_off_unclosed_trailing_comment.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__fmt_off_unclosed_trailing_comment.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/fmt_off_unclosed_trailing_comment.py --- ## Input -```py +```python # Regression test for https://github.com/astral-sh/ruff/issues/8211 # fmt: off @@ -15,7 +15,7 @@ class A: ``` ## Output -```py +```python # Regression test for https://github.com/astral-sh/ruff/issues/8211 # fmt: off diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__form_feed.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__form_feed.py.snap index ba62839bd8149..e5fb8812dc73c 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__form_feed.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__form_feed.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/form_feed.py --- ## Input -```py +```python # fmt: off # DB layer (form feed at the start of the next line) @@ -14,7 +14,7 @@ def test(): ``` ## Output -```py +```python # fmt: off # DB layer (form feed at the start of the next line) diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__indent.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__indent.py.snap index 2fe15cafc0e96..87873bcc8a203 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__indent.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__indent.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/indent.py --- ## Input -```py +```python ``` ## Outputs @@ -17,7 +17,7 @@ magic-trailing-comma = Respect preview = Disabled ``` -```py +```python ``` @@ -31,7 +31,7 @@ magic-trailing-comma = Respect preview = Disabled ``` -```py +```python ``` @@ -45,7 +45,7 @@ magic-trailing-comma = Respect preview = Disabled ``` -```py +```python ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__last_statement.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__last_statement.py.snap index 07d0eeaf0c52c..311edae5520f0 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__last_statement.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__last_statement.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/last_statement.py --- ## Input -```py +```python def test(): # fmt: off @@ -17,7 +17,7 @@ a + b # formatted ``` ## Output -```py +```python def test(): # fmt: off diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__mixed_space_and_tab.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__mixed_space_and_tab.py.snap index 73e4ed68a80b8..619cb49876d8d 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__mixed_space_and_tab.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__mixed_space_and_tab.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/mixed_space_and_tab.py --- ## Input -```py +```python def test(): # fmt: off a_very_small_indent @@ -32,7 +32,7 @@ magic-trailing-comma = Respect preview = Disabled ``` -```py +```python def test(): # fmt: off a_very_small_indent @@ -62,7 +62,7 @@ magic-trailing-comma = Respect preview = Disabled ``` -```py +```python def test(): # fmt: off a_very_small_indent @@ -92,7 +92,7 @@ magic-trailing-comma = Respect preview = Disabled ``` -```py +```python def test(): # fmt: off a_very_small_indent diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__newlines.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__newlines.py.snap index d7041c2e793fa..9faec5b646aac 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__newlines.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__newlines.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/newlines.py --- ## Input -```py +```python def func(): pass # fmt: off @@ -43,7 +43,7 @@ def func(): ``` ## Output -```py +```python def func(): pass diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__no_fmt_on.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__no_fmt_on.py.snap index 15ded04ff663c..38ebe93bfea5c 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__no_fmt_on.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__no_fmt_on.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/no_fmt_on.py --- ## Input -```py +```python def test(): # fmt: off not formatted @@ -16,7 +16,7 @@ a + b ``` ## Output -```py +```python def test(): # fmt: off not formatted diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__off_on_off_on.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__off_on_off_on.py.snap index c33f5faa9b76a..c06d40dd9cd30 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__off_on_off_on.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__off_on_off_on.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/off_on_off_on.py --- ## Input -```py +```python # Tricky sequences of fmt off and on # Formatted @@ -78,7 +78,7 @@ a + b ``` ## Output -```py +```python # Tricky sequences of fmt off and on # Formatted diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__simple.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__simple.py.snap index e9f968a425075..a8286e4691ed0 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__simple.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__simple.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/simple.py --- ## Input -```py +```python # Get's formatted a + b @@ -16,7 +16,7 @@ a + b ``` ## Output -```py +```python # Get's formatted a + b diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__trailing_comments.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__trailing_comments.py.snap index 89308b0d8a99d..948572efbbf83 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__trailing_comments.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__trailing_comments.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/trailing_comments.py --- ## Input -```py +```python a = 10 # fmt: off @@ -47,7 +47,7 @@ def test3 (): ``` ## Output -```py +```python a = 10 # fmt: off diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__trailing_semicolon.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__trailing_semicolon.py.snap index 463294c542dc0..1fba95d615401 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__trailing_semicolon.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__trailing_semicolon.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/trailing_semicolon.py --- ## Input -```py +```python def f(): # fmt: off a = 10 @@ -34,7 +34,7 @@ last_statement_with_semi ; ``` ## Output -```py +```python def f(): # fmt: off a = 10 diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__yapf.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__yapf.py.snap index 45f0ad07d0ea0..87940f270941b 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__yapf.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__yapf.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/yapf.py --- ## Input -```py +```python # Get's formatted a + b @@ -24,7 +24,7 @@ a + b ``` ## Output -```py +```python # Get's formatted a + b diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__decorators.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__decorators.py.snap index 720890d63353e..563c35b5d4536 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__decorators.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__decorators.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_skip/decorators.py --- ## Input -```py +```python @FormattedDecorator(a =b) # leading comment @@ -39,7 +39,7 @@ def foo(): # fmt: skip ``` ## Output -```py +```python @FormattedDecorator(a=b) # leading comment @MyDecorator( # dangling comment diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__docstrings.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__docstrings.py.snap index ffb045fff81b5..72456f720c067 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__docstrings.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__docstrings.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_skip/docstrings.py --- ## Input -```py +```python def test(): # leading comment """ This docstring does not @@ -20,7 +20,7 @@ def test(): ``` ## Output -```py +```python def test(): # leading comment """ This docstring does not diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__match.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__match.py.snap index 9c184bdad0708..9d8481a05830b 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__match.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__match.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_skip/match.py --- ## Input -```py +```python def http_error(status): match status : # fmt: skip case 400 : # fmt: skip @@ -80,7 +80,7 @@ match point: ``` ## Output -```py +```python def http_error(status): match status : # fmt: skip case 400 : # fmt: skip diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__or_else.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__or_else.py.snap index 4293169e6bb0b..d68da5658d630 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__or_else.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__or_else.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_skip/or_else.py --- ## Input -```py +```python for item in container: if search_something(item): # Found it! @@ -38,7 +38,7 @@ finally : # fmt: skip ``` ## Output -```py +```python for item in container: if search_something(item): # Found it! diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__parentheses.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__parentheses.py.snap index 30d4872aed1a5..27719c174afc6 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__parentheses.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__parentheses.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_skip/parentheses.py --- ## Input -```py +```python if ( # a leading condition comment len([1, 23, 3, 4, 5]) > 2 # trailing condition comment @@ -27,7 +27,7 @@ if ( # trailing open parentheses comment ``` ## Output -```py +```python if ( # a leading condition comment len([1, 23, 3, 4, 5]) > 2 # trailing condition comment diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__trailing_semi.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__trailing_semi.py.snap index 79c46bf7fce7d..55c9a112e843a 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__trailing_semi.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__trailing_semi.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_skip/trailing_semi.py --- ## Input -```py +```python x = 1; # fmt: skip x = 1 ; # fmt: skip @@ -17,7 +17,7 @@ _; #unrelated semicolon ``` ## Output -```py +```python x = 1; # fmt: skip x = 1 ; # fmt: skip diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__type_params.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__type_params.py.snap index 9bc2f32e01ccd..e38376ca8dabe 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__type_params.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__type_params.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_skip/type_params.py --- ## Input -```py +```python class TestTypeParam[ T ]: # fmt: skip pass @@ -45,7 +45,7 @@ def test [ ``` ## Output -```py +```python class TestTypeParam[ T ]: # fmt: skip pass diff --git a/crates/ruff_python_formatter/tests/snapshots/format@form_feed.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@form_feed.py.snap index f57c3801190c1..c6a5a26dbfa04 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@form_feed.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@form_feed.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/form_feed.py --- ## Input -```py +```python # Regression test for: https://github.com/astral-sh/ruff/issues/7624 if symbol is not None: request["market"] = market["id"] @@ -13,7 +13,7 @@ else: ``` ## Output -```py +```python # Regression test for: https://github.com/astral-sh/ruff/issues/7624 if symbol is not None: request["market"] = market["id"] diff --git a/crates/ruff_python_formatter/tests/snapshots/format@module_dangling_comment1.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@module_dangling_comment1.py.snap index eb28317e4a977..34f9219fb3577 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@module_dangling_comment1.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@module_dangling_comment1.py.snap @@ -3,14 +3,14 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/module_dangling_comment1.py --- ## Input -```py +```python __all__ = ["X", "XK", "Xatom", "Xcursorfont", "Xutil", "display", "error", "rdb"] # Shared types throughout the stub ``` ## Output -```py +```python __all__ = ["X", "XK", "Xatom", "Xcursorfont", "Xutil", "display", "error", "rdb"] # Shared types throughout the stub diff --git a/crates/ruff_python_formatter/tests/snapshots/format@module_dangling_comment2.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@module_dangling_comment2.py.snap index c419b524cadf6..768e829c77089 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@module_dangling_comment2.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@module_dangling_comment2.py.snap @@ -3,13 +3,13 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/module_dangling_comment2.py --- ## Input -```py +```python __all__ = ["X", "XK", "Xatom", "Xcursorfont", "Xutil", "display", "error", "rdb"] # Shared types throughout the stub ``` ## Output -```py +```python __all__ = ["X", "XK", "Xatom", "Xcursorfont", "Xutil", "display", "error", "rdb"] # Shared types throughout the stub ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@newlines.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@newlines.py.snap index eacf5fe7938d4..e939aa2d280a6 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@newlines.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@newlines.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/newlines.py --- ## Input -```py +```python ### # Blank lines around functions ### @@ -262,7 +262,7 @@ if True: pass``` ## Output -```py +```python ### # Blank lines around functions ### diff --git a/crates/ruff_python_formatter/tests/snapshots/format@newlines.pyi.snap b/crates/ruff_python_formatter/tests/snapshots/format@newlines.pyi.snap index cf9a8722b2380..98a8c15e96d48 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@newlines.pyi.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@newlines.pyi.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/newlines.pyi --- ## Input -```py +```python ### # Blank lines around functions ### @@ -168,7 +168,7 @@ x = 1 ``` ## Output -```py +```python ### # Blank lines around functions ### diff --git a/crates/ruff_python_formatter/tests/snapshots/format@parentheses__call_chains.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@parentheses__call_chains.py.snap index e448447ba18f5..1dfd3e8f7c79d 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@parentheses__call_chains.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@parentheses__call_chains.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/parentheses/call_chains.py --- ## Input -```py +```python # Test cases for call chains and optional parentheses, with and without fluent style raise OsError("") from a.aaaaa( @@ -225,7 +225,7 @@ max_message_id = ( ``` ## Output -```py +```python # Test cases for call chains and optional parentheses, with and without fluent style raise OsError("") from a.aaaaa( diff --git a/crates/ruff_python_formatter/tests/snapshots/format@parentheses__expression_parentheses_comments.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@parentheses__expression_parentheses_comments.py.snap index c8afee3d43f44..625d83e17178c 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@parentheses__expression_parentheses_comments.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@parentheses__expression_parentheses_comments.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/parentheses/expression_parentheses_comments.py --- ## Input -```py +```python list_with_parenthesized_elements1 = [ # comment leading outer ( @@ -120,7 +120,7 @@ x = ( ``` ## Output -```py +```python list_with_parenthesized_elements1 = [ # comment leading outer ( diff --git a/crates/ruff_python_formatter/tests/snapshots/format@parentheses__nested.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@parentheses__nested.py.snap index b9052fb1ac4e2..3616fa2267daf 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@parentheses__nested.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@parentheses__nested.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/parentheses/nested.py --- ## Input -```py +```python a1 = f( # 1 g( # 2 ) @@ -60,7 +60,7 @@ b3 = ( ``` ## Output -```py +```python a1 = f( # 1 g( # 2 ) diff --git a/crates/ruff_python_formatter/tests/snapshots/format@parentheses__opening_parentheses_comment_empty.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@parentheses__opening_parentheses_comment_empty.py.snap index 7f619ec37fa1f..126da8e6e3800 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@parentheses__opening_parentheses_comment_empty.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@parentheses__opening_parentheses_comment_empty.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/parentheses/opening_parentheses_comment_empty.py --- ## Input -```py +```python # Opening parentheses end-of-line comment without a value in the parentheses ( # a 1 @@ -93,7 +93,7 @@ f3 = { # f3 ``` ## Output -```py +```python # Opening parentheses end-of-line comment without a value in the parentheses ( # a 1 diff --git a/crates/ruff_python_formatter/tests/snapshots/format@parentheses__opening_parentheses_comment_value.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@parentheses__opening_parentheses_comment_value.py.snap index 5e387b26fa3fc..4c226dd8c3d9a 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@parentheses__opening_parentheses_comment_value.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@parentheses__opening_parentheses_comment_value.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/parentheses/opening_parentheses_comment_value.py --- ## Input -```py +```python # Opening parentheses end-of-line comment with value in the parentheses ( # a 1 @@ -157,7 +157,7 @@ f5 = { # f5 ``` ## Output -```py +```python # Opening parentheses end-of-line comment with value in the parentheses ( # a 1 diff --git a/crates/ruff_python_formatter/tests/snapshots/format@preview.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@preview.py.snap index f37b61a77bf1c..f7167deef5e09 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@preview.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@preview.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/preview.py --- ## Input -```py +```python """ Black's `Preview.module_docstring_newlines` """ @@ -83,7 +83,7 @@ magic-trailing-comma = Respect preview = Disabled ``` -```py +```python """ Black's `Preview.module_docstring_newlines` """ @@ -162,7 +162,7 @@ magic-trailing-comma = Respect preview = Enabled ``` -```py +```python """ Black's `Preview.module_docstring_newlines` """ diff --git a/crates/ruff_python_formatter/tests/snapshots/format@skip_magic_trailing_comma.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@skip_magic_trailing_comma.py.snap index 33d610669c71d..1434f6a964a93 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@skip_magic_trailing_comma.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@skip_magic_trailing_comma.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/skip_magic_trailing_comma.py --- ## Input -```py +```python ( "First entry", "Second entry", @@ -50,7 +50,7 @@ magic-trailing-comma = Respect preview = Disabled ``` -```py +```python ( "First entry", "Second entry", @@ -103,7 +103,7 @@ magic-trailing-comma = Ignore preview = Disabled ``` -```py +```python ("First entry", "Second entry", "last with trailing comma") ("First entry", "Second entry", "last without trailing comma") diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__ann_assign.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__ann_assign.py.snap index 83dcc0fbac867..69490f3caf53c 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__ann_assign.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__ann_assign.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/ann_assign.py --- ## Input -```py +```python # Regression test: Don't forget the parentheses in the value when breaking aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: int = a + 1 * a @@ -29,7 +29,7 @@ class DefaultRunner: ``` ## Output -```py +```python # Regression test: Don't forget the parentheses in the value when breaking aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: int = ( a + 1 * a diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__assert.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__assert.py.snap index 8f502dfe0afb3..0193312898a7f 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__assert.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__assert.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/assert.py --- ## Input -```py +```python assert True # Trailing same-line assert True is True # Trailing same-line assert 1, "Some string" # Trailing same-line @@ -178,7 +178,7 @@ assert package.files == [ ``` ## Output -```py +```python assert True # Trailing same-line assert True is True # Trailing same-line assert 1, "Some string" # Trailing same-line diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__assign.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__assign.py.snap index 590a617f61623..075824ab64f32 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__assign.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__assign.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/assign.py --- ## Input -```py +```python # break left hand side a1akjdshflkjahdslkfjlasfdahjlfds = bakjdshflkjahdslkfjlasfdahjlfds = cakjdshflkjahdslkfjlasfdahjlfds = kjaödkjaföjfahlfdalfhaöfaöfhaöfha = fkjaödkjaföjfahlfdalfhaöfaöfhaöfha = g = 3 @@ -76,7 +76,7 @@ def main() -> None: ``` ## Output -```py +```python # break left hand side a1akjdshflkjahdslkfjlasfdahjlfds = ( bakjdshflkjahdslkfjlasfdahjlfds diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__aug_assign.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__aug_assign.py.snap index 715c6cd1541e1..583b2f7c63d63 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__aug_assign.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__aug_assign.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/aug_assign.py --- ## Input -```py +```python tree_depth += 1 greeting += "This is very long, formal greeting for whomever is name here. Dear %s, it will break the line" % len( @@ -12,7 +12,7 @@ greeting += "This is very long, formal greeting for whomever is name here. Dear ``` ## Output -```py +```python tree_depth += 1 greeting += ( diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__break.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__break.py.snap index 1cffa28bec002..f7e6ec7f46b88 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__break.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__break.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/break.py --- ## Input -```py +```python # leading comment while True: # block comment # inside comment @@ -12,7 +12,7 @@ while True: # block comment ``` ## Output -```py +```python # leading comment while True: # block comment # inside comment diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__class_definition.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__class_definition.py.snap index d555951aa2b01..de82b7126c37a 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__class_definition.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__class_definition.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/class_definition.py --- ## Input -```py +```python # comment class Test( @@ -233,7 +233,7 @@ class QuerySet(AltersData): ``` ## Output -```py +```python # comment diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__delete.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__delete.py.snap index 2afea0bb26dd2..931b4a6da72d1 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__delete.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__delete.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/delete.py --- ## Input -```py +```python x = 1 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 1 a, b, c, d = 1, 2, 3, 4 @@ -86,7 +86,7 @@ del ( # dangling end of line comment ``` ## Output -```py +```python x = 1 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 1 a, b, c, d = 1, 2, 3, 4 diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__ellipsis.pyi.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__ellipsis.pyi.snap index 543c45b5c95a3..756fbff9f8e34 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__ellipsis.pyi.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__ellipsis.pyi.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/ellipsis.pyi --- ## Input -```py +```python """Compound statements with no body should be written on one line.""" if True: @@ -108,7 +108,7 @@ finally: ... # comment``` ## Output -```py +```python """Compound statements with no body should be written on one line.""" if True: ... diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__for.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__for.py.snap index 1ff6cc43104ab..fbf7fb7e754f2 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__for.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__for.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/for.py --- ## Input -```py +```python for x in y: # trailing test comment pass # trailing last statement comment @@ -79,7 +79,7 @@ for ( ``` ## Output -```py +```python for x in y: # trailing test comment pass # trailing last statement comment diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__function.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__function.py.snap index a5ef8fe28fab8..5b0684becdfa4 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__function.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__function.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/function.py --- ## Input -```py +```python # Dangling comments def test( # comment @@ -419,7 +419,7 @@ def default_arg_comments2(# ``` ## Output -```py +```python # Dangling comments def test( # comment diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__global.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__global.py.snap index 1209b7c3f5a86..27743bbf794ad 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__global.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__global.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/global.py --- ## Input -```py +```python def f(): global x, y, z @@ -23,7 +23,7 @@ def f(): ``` ## Output -```py +```python def f(): global x, y, z diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__if.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__if.py.snap index cc73bca847797..7ebc5fab3641b 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__if.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__if.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/if.py --- ## Input -```py +```python # 1 leading if comment if x == y: # 2 trailing if condition # 3 leading pass @@ -303,7 +303,7 @@ if parent_body: ``` ## Output -```py +```python # 1 leading if comment if x == y: # 2 trailing if condition # 3 leading pass diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__import.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__import.py.snap index 336ee1db4fd2b..00ab19b271bc6 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__import.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__import.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/import.py --- ## Input -```py +```python from a import aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa from a import aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa, aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa from a import aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa as dfgsdfgsd, aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa as sdkjflsdjlahlfd @@ -94,7 +94,7 @@ x = 1 ``` ## Output -```py +```python from a import ( aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa, ) diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__import_from.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__import_from.py.snap index af7f8e1fa0e0e..d650fd8548119 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__import_from.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__import_from.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/import_from.py --- ## Input -```py +```python from a import aksjdhflsakhdflkjsadlfajkslhf from a import ( aksjdhflsakhdflkjsadlfajkslhf, @@ -46,7 +46,7 @@ from tqdm . auto import tqdm ``` ## Output -```py +```python from a import aksjdhflsakhdflkjsadlfajkslhf from a import ( aksjdhflsakhdflkjsadlfajkslhf, diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__match.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__match.py.snap index aaad3203bc943..01e0715610701 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__match.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__match.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/match.py --- ## Input -```py +```python # leading match comment match foo: # dangling match comment case "bar": @@ -587,7 +587,7 @@ match n % 3, n % 5: ``` ## Output -```py +```python # leading match comment match foo: # dangling match comment case "bar": diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__module_comment.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__module_comment.py.snap index 1ba55d8a77352..075458da5ac73 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__module_comment.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__module_comment.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/module_comment.py --- ## Input -```py +```python @@ -11,7 +11,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/ ``` ## Output -```py +```python # hehehe >:)a ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__nonlocal.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__nonlocal.py.snap index bbdcb3046d383..c9fc2a5993a84 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__nonlocal.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__nonlocal.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/nonlocal.py --- ## Input -```py +```python def f(): nonlocal x, y, z @@ -23,7 +23,7 @@ def f(): ``` ## Output -```py +```python def f(): nonlocal x, y, z diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__raise.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__raise.py.snap index 46637a35435a4..3871a907f5f1e 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__raise.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__raise.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/raise.py --- ## Input -```py +```python raise a from aksjdhflsakhdflkjsadlfajkslhf raise a from (aksjdhflsakhdflkjsadlfajkslhf,) raise (aaaaa.aaa(a).a) from (aksjdhflsakhdflkjsadlfajkslhf) @@ -92,7 +92,7 @@ raise hello( # sould I stay here ``` ## Output -```py +```python raise a from aksjdhflsakhdflkjsadlfajkslhf raise a from (aksjdhflsakhdflkjsadlfajkslhf,) raise (aaaaa.aaa(a).a) from (aksjdhflsakhdflkjsadlfajkslhf) diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__return.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__return.py.snap index 9937f29918038..8ea03f92116a8 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__return.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__return.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/return.py --- ## Input -```py +```python return len(self.nodeseeeeeeeee), sum( len(node.parents) for node in self.node_map.values() @@ -55,7 +55,7 @@ def f(): ``` ## Output -```py +```python return len(self.nodeseeeeeeeee), sum( len(node.parents) for node in self.node_map.values() ) diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__return_annotation.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__return_annotation.py.snap index 1f331852019ec..d32669cbbc5b6 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__return_annotation.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__return_annotation.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/return_annotation.py --- ## Input -```py +```python # Handle comments on empty tuple return types. def zrevrangebylex(self, name: _Key, max: _Value, min: _Value, start: int | None = None, num: int | None = None) -> ( # type: ignore[override] ): ... @@ -201,7 +201,7 @@ def process_board_action( ``` ## Output -```py +```python # Handle comments on empty tuple return types. def zrevrangebylex( self, diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__top_level.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__top_level.py.snap index 7549ab861ed48..da86b86473607 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__top_level.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__top_level.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/top_level.py --- ## Input -```py +```python class A: def __init__(self): pass @@ -46,7 +46,7 @@ def quuz(): ``` ## Output -```py +```python class A: def __init__(self): pass diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__top_level.pyi.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__top_level.pyi.snap index 2e301df56a8f8..851369179a4f9 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__top_level.pyi.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__top_level.pyi.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/top_level.pyi --- ## Input -```py +```python class A: def __init__(self): pass @@ -98,7 +98,7 @@ class EllipsisWithLeadingComment: ``` ## Output -```py +```python class A: def __init__(self): pass diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__try.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__try.py.snap index 8750541e567ff..12409cfd84084 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__try.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__try.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/try.py --- ## Input -```py +```python try: pass except: @@ -175,7 +175,7 @@ finally: ``` ## Output -```py +```python try: pass except: diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__type_alias.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__type_alias.py.snap index 24df936b5a09d..ccc44b8db950a 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__type_alias.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__type_alias.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/type_alias.py --- ## Input -```py +```python # basic usage type X = int @@ -101,7 +101,7 @@ type bounds_trailing_comma[T: (a, b,)] = T ``` ## Output -```py +```python # basic usage type X = int diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__while.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__while.py.snap index 91f44fa7b9922..bc72ff726039c 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__while.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__while.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/while.py --- ## Input -```py +```python while 34: # trailing test comment pass # trailing last statement comment @@ -37,7 +37,7 @@ while ( ``` ## Output -```py +```python while 34: # trailing test comment pass # trailing last statement comment diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__with.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__with.py.snap index 145e04e5d4ffe..7b2280c6caf31 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__with.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__with.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/with.py --- ## Input -```py +```python with aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: pass # trailing @@ -312,7 +312,7 @@ if True: ``` ## Output -```py +```python with aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: pass # trailing diff --git a/crates/ruff_python_formatter/tests/snapshots/format@stub_files__comments.pyi.snap b/crates/ruff_python_formatter/tests/snapshots/format@stub_files__comments.pyi.snap index beb8e4a11eaae..299b986fd2058 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@stub_files__comments.pyi.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@stub_files__comments.pyi.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/comments.pyi --- ## Input -```py +```python class SupportsAnext: def __anext__(self): ... @@ -14,7 +14,7 @@ class SupportsDunderLT: ``` ## Output -```py +```python class SupportsAnext: def __anext__(self): ... diff --git a/crates/ruff_python_formatter/tests/snapshots/format@stub_files__nesting.pyi.snap b/crates/ruff_python_formatter/tests/snapshots/format@stub_files__nesting.pyi.snap index ba86351d1ad5a..68fd2614d4fc1 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@stub_files__nesting.pyi.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@stub_files__nesting.pyi.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/nesting.pyi --- ## Input -```py +```python """Tests specifically for https://github.com/psf/black/issues/3861""" import sys @@ -38,7 +38,7 @@ if sys.version_info > (3, 7): ``` ## Output -```py +```python """Tests specifically for https://github.com/psf/black/issues/3861""" import sys diff --git a/crates/ruff_python_formatter/tests/snapshots/format@stub_files__suite.pyi.snap b/crates/ruff_python_formatter/tests/snapshots/format@stub_files__suite.pyi.snap index cf4b0523c03c0..9edc789b5fabd 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@stub_files__suite.pyi.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@stub_files__suite.pyi.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/suite.pyi --- ## Input -```py +```python """Tests for empty line rules in stub files, mostly inspired by typeshed. The rules are a list of nested exceptions. See also https://github.com/psf/black/blob/c160e4b7ce30c661ac4f2dfa5038becf1b8c5c33/src/black/lines.py#L576-L744 @@ -156,7 +156,7 @@ class ComplexStatements: ``` ## Output -```py +```python """Tests for empty line rules in stub files, mostly inspired by typeshed. The rules are a list of nested exceptions. See also https://github.com/psf/black/blob/c160e4b7ce30c661ac4f2dfa5038becf1b8c5c33/src/black/lines.py#L576-L744 diff --git a/crates/ruff_python_formatter/tests/snapshots/format@stub_files__top_level.pyi.snap b/crates/ruff_python_formatter/tests/snapshots/format@stub_files__top_level.pyi.snap index 99c29acbdd457..d34c36b1a387d 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@stub_files__top_level.pyi.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@stub_files__top_level.pyi.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/top_level.pyi --- ## Input -```py +```python from typing import final @@ -24,7 +24,7 @@ class LockType4: ... ``` ## Output -```py +```python from typing import final def count1(): ... diff --git a/crates/ruff_python_formatter/tests/snapshots/format@tab_width.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@tab_width.py.snap index 0dbdcdf072348..2ff5d8afde9b6 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@tab_width.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@tab_width.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/tab_width.py --- ## Input -```py +```python # Fits with tab width 2 (1 + " 012345678901234567890123456789012345678901234567890123456789012345678901234567") @@ -25,7 +25,7 @@ magic-trailing-comma = Respect preview = Disabled ``` -```py +```python # Fits with tab width 2 (1 + " 012345678901234567890123456789012345678901234567890123456789012345678901234567") @@ -47,7 +47,7 @@ magic-trailing-comma = Respect preview = Disabled ``` -```py +```python # Fits with tab width 2 ( 1 @@ -72,7 +72,7 @@ magic-trailing-comma = Respect preview = Disabled ``` -```py +```python # Fits with tab width 2 ( 1 diff --git a/crates/ruff_python_formatter/tests/snapshots/format@trailing_comments.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@trailing_comments.py.snap index 50c7ab6296719..9dd7fade23961 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@trailing_comments.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@trailing_comments.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/trailing_comments.py --- ## Input -```py +```python # Pragma reserved width fixtures i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # noqa: This shouldn't break i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # NoQA: This shouldn't break @@ -38,7 +38,7 @@ i = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ``` ## Output -```py +```python # Pragma reserved width fixtures i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # noqa: This shouldn't break i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # NoQA: This shouldn't break diff --git a/crates/ruff_python_formatter/tests/snapshots/format@trivia.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@trivia.py.snap index e2b329f9ea0e2..598ee13df18fc 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@trivia.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@trivia.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/trivia.py --- ## Input -```py +```python # Removes the line above @@ -39,7 +39,7 @@ e = 50 # one empty line before ``` ## Output -```py +```python # Removes the line above a = 10 # Keeps the line above diff --git a/docs/faq.md b/docs/faq.md index 34c7b5e69a01a..858b38b57b3f0 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -245,14 +245,14 @@ isort treat inline comments in some cases (see: [#1381](https://github.com/astra For example, Ruff tends to group non-aliased imports from the same module: -```py +```python from numpy import cos, int8, int16, int32, int64, tan, uint8, uint16, uint32, uint64 from numpy import sin as np_sin ``` Whereas isort splits them into separate import statements at each aliased boundary: -```py +```python from numpy import cos, int8, int16, int32, int64 from numpy import sin as np_sin from numpy import tan, uint8, uint16, uint32, uint64 diff --git a/docs/tutorial.md b/docs/tutorial.md index 7eae80f290266..4e5f242daf4fd 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -21,7 +21,7 @@ numbers ...where `numbers.py` contains the following code: -```py +```python from typing import Iterable import os @@ -273,7 +273,7 @@ Found 3 errors. Any lint rule can be ignored by adding a `# noqa` comment to the line in question. For example, let's ignore the `UP035` rule for the `Iterable` import: -```py +```python from typing import Iterable # noqa: UP035 @@ -294,7 +294,7 @@ Found 3 errors. If we want to ignore a rule for an entire file, we can add the line `# ruff: noqa: {code}` anywhere in the file, preferably towards the top, like so: -```py +```python # ruff: noqa: UP035 from typing import Iterable