From 4fdf97a95c4e18cf2547916fb082d2c02bd7c410 Mon Sep 17 00:00:00 2001 From: doolio Date: Thu, 9 Nov 2023 02:49:24 +0100 Subject: [PATCH] Apply consistent code block labels (#8563) This ensures the python label is used for all python code blocks for consistency. ## Test Plan Visual inspection of all changes via git client ensuring no other changes were made in error. --- crates/ruff_linter/src/checkers/ast/mod.rs | 4 ++-- crates/ruff_linter/src/importer/insertion.rs | 2 +- crates/ruff_linter/src/importer/mod.rs | 2 +- .../ruff_python_formatter/tests/fixtures.rs | 19 ++++++++++++------- ...mpatibility@conditional_expression.py.snap | 6 +++--- ...ibility@miscellaneous__blackd_diff.py.snap | 6 +++--- ...ility@miscellaneous__debug_visitor.py.snap | 6 +++--- ...tibility@miscellaneous__decorators.py.snap | 6 +++--- ..._docstring_no_string_normalization.py.snap | 6 +++--- ...ng_preview_no_string_normalization.py.snap | 6 +++--- ...atibility@miscellaneous__force_pyi.py.snap | 6 +++--- ...aneous__long_strings_flag_disabled.py.snap | 6 +++--- ...ty@miscellaneous__power_op_newline.py.snap | 6 +++--- ...ility@miscellaneous__string_quotes.py.snap | 6 +++--- ...ty@py_310__pattern_matching_extras.py.snap | 6 +++--- ...ity@py_310__pattern_matching_style.py.snap | 6 +++--- ...ompatibility@py_310__pep_572_py310.py.snap | 6 +++--- ...ility@py_38__pep_572_remove_parens.py.snap | 6 +++--- .../black_compatibility@raw_docstring.py.snap | 6 +++--- ...ses__comment_after_escaped_newline.py.snap | 6 +++--- ...patibility@simple_cases__comments2.py.snap | 6 +++--- ...patibility@simple_cases__comments6.py.snap | 6 +++--- ...patibility@simple_cases__comments9.py.snap | 6 +++--- ...tibility@simple_cases__composition.py.snap | 6 +++--- ...ses__composition_no_trailing_comma.py.snap | 6 +++--- ...ty@simple_cases__docstring_preview.py.snap | 6 +++--- ...atibility@simple_cases__expression.py.snap | 6 +++--- ...mpatibility@simple_cases__fmtonoff.py.snap | 6 +++--- ...patibility@simple_cases__fmtonoff4.py.snap | 6 +++--- ...patibility@simple_cases__fmtonoff5.py.snap | 6 +++--- ...lity@simple_cases__fmtpass_imports.py.snap | 6 +++--- ...mpatibility@simple_cases__fmtskip5.py.snap | 6 +++--- ...mpatibility@simple_cases__function.py.snap | 6 +++--- ...patibility@simple_cases__function2.py.snap | 6 +++--- ...atibility@simple_cases__ignore_pyi.py.snap | 6 +++--- ...onsecutive_open_parentheses_ignore.py.snap | 6 +++--- ...@simple_cases__remove_await_parens.py.snap | 6 +++--- ...simple_cases__remove_except_parens.py.snap | 6 +++--- ...@simple_cases__remove_for_brackets.py.snap | 6 +++--- ..._cases__return_annotation_brackets.py.snap | 6 +++--- ...ompatibility@simple_cases__torture.py.snap | 6 +++--- ...__trailing_commas_in_leading_parts.py.snap | 6 +++--- ...tibility@simple_cases__tupleassign.py.snap | 6 +++--- .../format@carriage_return__string.py.snap | 4 ++-- .../tests/snapshots/format@docstring.py.snap | 10 +++++----- ...t@empty_multiple_trailing_newlines.py.snap | 4 ++-- .../format@empty_now_newline.py.snap | 4 ++-- .../format@empty_trailing_newline.py.snap | 4 ++-- .../snapshots/format@empty_whitespace.py.snap | 4 ++-- ...ormat@expression__annotated_assign.py.snap | 4 ++-- .../format@expression__attribute.py.snap | 4 ++-- .../format@expression__await.py.snap | 4 ++-- .../format@expression__binary.py.snap | 4 ++-- ...expression__binary_implicit_string.py.snap | 4 ++-- ...mat@expression__binary_pow_spacing.py.snap | 4 ++-- ...rmat@expression__boolean_operation.py.snap | 4 ++-- .../format@expression__bytes.py.snap | 6 +++--- .../snapshots/format@expression__call.py.snap | 4 ++-- .../format@expression__compare.py.snap | 4 ++-- .../snapshots/format@expression__dict.py.snap | 4 ++-- .../format@expression__dict_comp.py.snap | 4 ++-- .../format@expression__fstring.py.snap | 4 ++-- .../format@expression__generator_exp.py.snap | 4 ++-- .../snapshots/format@expression__if.py.snap | 4 ++-- .../format@expression__lambda.py.snap | 4 ++-- .../snapshots/format@expression__list.py.snap | 4 ++-- .../format@expression__list_comp.py.snap | 4 ++-- .../format@expression__named_expr.py.snap | 4 ++-- .../format@expression__number.py.snap | 4 ++-- ...ion__optional_parentheses_comments.py.snap | 4 ++-- .../format@expression__set_comp.py.snap | 4 ++-- .../format@expression__slice.py.snap | 4 ++-- ...t@expression__split_empty_brackets.py.snap | 4 ++-- .../format@expression__starred.py.snap | 4 ++-- .../format@expression__string.py.snap | 6 +++--- .../format@expression__subscript.py.snap | 4 ++-- .../format@expression__tuple.py.snap | 4 ++-- .../format@expression__unary.py.snap | 4 ++-- .../format@expression__unsplittable.py.snap | 4 ++-- .../format@expression__yield.py.snap | 4 ++-- .../format@expression__yield_from.py.snap | 4 ++-- .../format@fmt_on_off__comments.py.snap | 4 ++-- .../format@fmt_on_off__empty_file.py.snap | 4 ++-- ...rmat@fmt_on_off__fmt_off_docstring.py.snap | 6 +++--- ...losed_deep_nested_trailing_comment.py.snap | 4 ++-- ..._fmt_off_unclosed_trailing_comment.py.snap | 4 ++-- .../format@fmt_on_off__form_feed.py.snap | 4 ++-- .../format@fmt_on_off__indent.py.snap | 8 ++++---- .../format@fmt_on_off__last_statement.py.snap | 4 ++-- ...at@fmt_on_off__mixed_space_and_tab.py.snap | 8 ++++---- .../format@fmt_on_off__newlines.py.snap | 4 ++-- .../format@fmt_on_off__no_fmt_on.py.snap | 4 ++-- .../format@fmt_on_off__off_on_off_on.py.snap | 4 ++-- .../format@fmt_on_off__simple.py.snap | 4 ++-- ...rmat@fmt_on_off__trailing_comments.py.snap | 4 ++-- ...mat@fmt_on_off__trailing_semicolon.py.snap | 4 ++-- .../snapshots/format@fmt_on_off__yapf.py.snap | 4 ++-- .../format@fmt_skip__decorators.py.snap | 4 ++-- .../format@fmt_skip__docstrings.py.snap | 4 ++-- .../snapshots/format@fmt_skip__match.py.snap | 4 ++-- .../format@fmt_skip__or_else.py.snap | 4 ++-- .../format@fmt_skip__parentheses.py.snap | 4 ++-- .../format@fmt_skip__trailing_semi.py.snap | 4 ++-- .../format@fmt_skip__type_params.py.snap | 4 ++-- .../tests/snapshots/format@form_feed.py.snap | 4 ++-- .../format@module_dangling_comment1.py.snap | 4 ++-- .../format@module_dangling_comment2.py.snap | 4 ++-- .../tests/snapshots/format@newlines.py.snap | 4 ++-- .../tests/snapshots/format@newlines.pyi.snap | 4 ++-- .../format@parentheses__call_chains.py.snap | 4 ++-- ...s__expression_parentheses_comments.py.snap | 4 ++-- .../format@parentheses__nested.py.snap | 4 ++-- ..._opening_parentheses_comment_empty.py.snap | 4 ++-- ..._opening_parentheses_comment_value.py.snap | 4 ++-- .../tests/snapshots/format@preview.py.snap | 6 +++--- .../format@skip_magic_trailing_comma.py.snap | 6 +++--- .../format@statement__ann_assign.py.snap | 4 ++-- .../format@statement__assert.py.snap | 4 ++-- .../format@statement__assign.py.snap | 4 ++-- .../format@statement__aug_assign.py.snap | 4 ++-- .../snapshots/format@statement__break.py.snap | 4 ++-- ...format@statement__class_definition.py.snap | 4 ++-- .../format@statement__delete.py.snap | 4 ++-- .../format@statement__ellipsis.pyi.snap | 4 ++-- .../snapshots/format@statement__for.py.snap | 4 ++-- .../format@statement__function.py.snap | 4 ++-- .../format@statement__global.py.snap | 4 ++-- .../snapshots/format@statement__if.py.snap | 4 ++-- .../format@statement__import.py.snap | 4 ++-- .../format@statement__import_from.py.snap | 4 ++-- .../snapshots/format@statement__match.py.snap | 4 ++-- .../format@statement__module_comment.py.snap | 4 ++-- .../format@statement__nonlocal.py.snap | 4 ++-- .../snapshots/format@statement__raise.py.snap | 4 ++-- .../format@statement__return.py.snap | 4 ++-- ...ormat@statement__return_annotation.py.snap | 4 ++-- .../format@statement__top_level.py.snap | 4 ++-- .../format@statement__top_level.pyi.snap | 4 ++-- .../snapshots/format@statement__try.py.snap | 4 ++-- .../format@statement__type_alias.py.snap | 4 ++-- .../snapshots/format@statement__while.py.snap | 4 ++-- .../snapshots/format@statement__with.py.snap | 4 ++-- .../format@stub_files__comments.pyi.snap | 4 ++-- .../format@stub_files__nesting.pyi.snap | 4 ++-- .../format@stub_files__suite.pyi.snap | 4 ++-- .../format@stub_files__top_level.pyi.snap | 4 ++-- .../tests/snapshots/format@tab_width.py.snap | 8 ++++---- .../format@trailing_comments.py.snap | 4 ++-- .../tests/snapshots/format@trivia.py.snap | 4 ++-- docs/faq.md | 4 ++-- docs/tutorial.md | 6 +++--- 151 files changed, 364 insertions(+), 359 deletions(-) diff --git a/crates/ruff_linter/src/checkers/ast/mod.rs b/crates/ruff_linter/src/checkers/ast/mod.rs index c3acf77ce8..f56966e669 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 01b442dce5..4a2c782c18 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 5241aa4f4c..4624f12f68 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 604d79bbae..7c11a1beb7 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 f7012d70b5..8a1f4efdd8 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 835d6e4d60..5a0a7e590e 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 5d7941640f..36233a64ec 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 43d3d15eda..9eaba761d4 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 0b680fd94c..bdc68fe77b 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 4503b0dd00..a2969f3e40 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 678606a9ed..4eeadc7a82 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 991b20198c..554b9b0fb3 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 991e030ac9..b9ff9703eb 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 4600e1fd20..41d92b73c6 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 3f7ef28e90..865bb18e44 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 b73b0f87fa..51669107f8 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 b8d306b641..b694f46cfd 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 daea36ba7e..49c78e6559 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 8177e7d37f..25946da099 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 5a209c5759..9656ed1e16 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 0e98a11642..9c0622bce3 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 6725d8d840..45ab60a21a 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 ede65b6951..743906edda 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 fbda66e07b..756ef81dd3 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 06bcb6b4e7..89664dc7c1 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 dad30c4cb8..afb73efb11 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 02a6a4a76c..ea14186d29 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 ce417c728b..2df0b531f8 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 5962f31f5f..529e50d32c 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 a3b86b9e60..a531a87c05 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 7d2474337a..8dceca43bc 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 58985692cd..597ccdeeba 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 dacb0b6cac..317d6c6a18 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 2d1ed7c6ad..2fc0696b9b 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 d12ec42a82..9027c47633 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 7759ca34bc..66ce78e5b1 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 428ca61376..a72df1daba 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 1b9f9e5d08..a0459420e5 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 9a32084e95..3c2eb7eab6 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 552ca4576b..fd67777f13 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 f44e1053f0..6b7ddaa378 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 514ea6258a..8ad0695b04 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 d2bc4735ae..16f034ed48 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 522538378a..97df9f7e82 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 dc942c6320..4e92b7c09d 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 acae2f4cc3..5582da34d9 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 77fbee7d91..cc9ebfcc7e 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 a89a4db2c6..516325c9df 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 33604dc12f..48184db5a3 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 55c646d9fd..0ce76c8751 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 0e4951e92a..bbcc0efd95 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 f01cb0d85f..fa8d86bf52 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 eb9f911a4e..e245378863 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 286353d24f..5f3c84a8df 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 c22840f9f2..f54dfeb51c 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 819040b366..74c03816e9 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 158e4f65c6..1e8baabd73 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 861c4f0553..1b35bce81b 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 6498068ee8..314a53513b 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 3745b5bdce..6ecda476dd 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 df00b778e8..56181cd10a 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 5d39862c2d..d9bc028763 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 bce2611ab0..4818acca87 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 7aa5a080c8..e73a5515f3 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 241f61a481..e9874be9de 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 1d00f6ae54..b798984c65 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 a7007f72e4..316630a83f 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 68a74972a0..8221398aa9 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 feea8103e0..fe8a33ef8e 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 1cf74fe785..4279cd03f2 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 4244dd1318..b73d9a599e 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 9ba98aaef7..3063466678 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 c923784d04..810964acc1 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 2393ae56af..225242f034 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 28ebcfd850..09830dae06 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 102175f3d5..35f5f5e929 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 0f8997294a..1aa67094d5 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 6146fd82d5..0d80fc1a25 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 95ec4e212e..a40713b2d1 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 463ed0d1ec..0d591cc737 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 3439eafe70..cfbea8ba9a 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 ad353b6d2f..a84753bdf6 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 7dbe39d5d1..ea604491f3 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 2315411c17..8cca1bee88 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 081eb52382..474830dfe1 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 14cf588e95..2fb64fea20 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 ba62839bd8..e5fb8812dc 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 2fe15cafc0..87873bcc8a 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 07d0eeaf0c..311edae552 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 73e4ed68a8..619cb49876 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 d7041c2e79..9faec5b646 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 15ded04ff6..38ebe93bfe 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 c33f5faa9b..c06d40dd9c 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 e9f968a425..a8286e4691 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 89308b0d8a..948572efbb 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 463294c542..1fba95d615 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 45f0ad07d0..87940f2709 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 720890d633..563c35b5d4 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 ffb045fff8..72456f720c 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 9c184bdad0..9d8481a058 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 4293169e6b..d68da5658d 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 30d4872aed..27719c174a 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 79c46bf7fc..55c9a112e8 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 9bc2f32e01..e38376ca8d 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 f57c380119..c6a5a26dbf 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 eb28317e4a..34f9219fb3 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 c419b524ca..768e829c77 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 eacf5fe793..e939aa2d28 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 cf9a8722b2..98a8c15e96 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 e448447ba1..1dfd3e8f7c 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 c8afee3d43..625d83e171 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 b9052fb1ac..3616fa2267 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 7f619ec37f..126da8e6e3 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 5e387b26fa..4c226dd8c3 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 f37b61a77b..f7167deef5 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 33d610669c..1434f6a964 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 83dcc0fbac..69490f3caf 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 8f502dfe0a..0193312898 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 590a617f61..075824ab64 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 715c6cd154..583b2f7c63 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 1cffa28bec..f7e6ec7f46 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 d555951aa2..de82b7126c 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 2afea0bb26..931b4a6da7 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 543c45b5c9..756fbff9f8 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 1ff6cc4310..fbf7fb7e75 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 a5ef8fe28f..5b0684becd 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 1209b7c3f5..27743bbf79 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 cc73bca847..7ebc5fab36 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 336ee1db4f..00ab19b271 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 af7f8e1fa0..d650fd8548 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 aaad3203bc..01e0715610 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 1ba55d8a77..075458da5a 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 bbdcb3046d..c9fc2a5993 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 46637a3543..3871a907f5 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 9937f29918..8ea03f9211 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 1f33185201..d32669cbbc 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 7549ab861e..da86b86473 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 2e301df56a..851369179a 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 8750541e56..12409cfd84 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 24df936b5a..ccc44b8db9 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 91f44fa7b9..bc72ff7260 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 145e04e5d4..7b2280c6ca 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 beb8e4a11e..299b986fd2 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 ba86351d1a..68fd2614d4 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 cf4b0523c0..9edc789b5f 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 99c29acbdd..d34c36b1a3 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 0dbdcdf072..2ff5d8afde 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 50c7ab6296..9dd7fade23 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 e2b329f9ea..598ee13df1 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 34c7b5e69a..858b38b57b 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 7eae80f290..4e5f242daf 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