From 6dffcf83e17e2a10388e32883a9a38d173ca11b5 Mon Sep 17 00:00:00 2001 From: yataka Date: Mon, 18 Nov 2024 22:29:27 +0900 Subject: [PATCH] Change default for Python version from 3.8 to 3.9 (#13896) Co-authored-by: Micha Reiser --- README.md | 4 +- crates/red_knot/src/target_version.rs | 14 + crates/red_knot_wasm/src/lib.rs | 14 + crates/ruff_linter/src/settings/types.rs | 6 +- .../cases/context_managers_38.options.json | 1 + ...ontext_managers_autodetect_38.options.json | 1 + ...review_allow_empty_first_line.options.json | 1 - .../cases/preview_allow_empty_first_line.py | 82 --- .../preview_allow_empty_first_line.py.expect | 81 --- ...y_first_line_in_special_cases.options.json | 1 - ...allow_empty_first_line_in_special_cases.py | 51 -- ...mpty_first_line_in_special_cases.py.expect | 51 -- .../cases/preview_async_stmts.options.json | 1 - .../black/cases/preview_async_stmts.py | 11 - .../black/cases/preview_async_stmts.py.expect | 11 - .../preview_context_managers_38.options.json | 1 - .../cases/preview_context_managers_38.py | 31 - .../preview_context_managers_38.py.expect | 18 - .../preview_context_managers_39.options.json | 1 - .../cases/preview_context_managers_39.py | 84 --- .../preview_context_managers_39.py.expect | 85 --- ...ntext_managers_autodetect_310.options.json | 1 - ...preview_context_managers_autodetect_310.py | 15 - ..._context_managers_autodetect_310.py.expect | 15 - ...ntext_managers_autodetect_311.options.json | 1 - ...preview_context_managers_autodetect_311.py | 16 - ..._context_managers_autodetect_311.py.expect | 16 - ...ontext_managers_autodetect_38.options.json | 1 - .../preview_context_managers_autodetect_38.py | 24 - ...w_context_managers_autodetect_38.py.expect | 19 - ...ontext_managers_autodetect_39.options.json | 1 - .../preview_context_managers_autodetect_39.py | 17 - ...w_context_managers_autodetect_39.py.expect | 14 - ...tring_no_string_normalization.options.json | 1 - ...eview_docstring_no_string_normalization.py | 10 - ...ocstring_no_string_normalization.py.expect | 10 - ...preview_dummy_implementations.options.json | 1 - .../cases/preview_dummy_implementations.py | 69 --- .../preview_dummy_implementations.py.expect | 72 --- .../cases/preview_form_feeds.options.json | 1 - .../black/cases/preview_form_feeds.py | 116 ---- .../black/cases/preview_form_feeds.py.expect | 103 ---- ...o_blank_line_before_docstring.options.json | 1 - .../preview_no_blank_line_before_docstring.py | 33 -- ...w_no_blank_line_before_docstring.py.expect | 28 - ...preview_pattern_matching_long.options.json | 1 - .../cases/preview_pattern_matching_long.py | 7 - .../preview_pattern_matching_long.py.expect | 23 - ...ttern_matching_trailing_comma.options.json | 1 - ...preview_pattern_matching_trailing_comma.py | 14 - ..._pattern_matching_trailing_comma.py.expect | 20 - .../black/cases/preview_pep_572.options.json | 1 - .../fixtures/black/cases/preview_pep_572.py | 2 - .../black/cases/preview_pep_572.py.expect | 2 - .../preview_percent_precedence.options.json | 1 - .../black/cases/preview_percent_precedence.py | 20 - .../preview_percent_precedence.py.expect | 20 - .../preview_power_op_spacing.options.json | 1 - .../black/cases/preview_power_op_spacing.py | 11 - .../cases/preview_power_op_spacing.py.expect | 83 --- .../preview_prefer_rhs_split.options.json | 1 - .../black/cases/preview_prefer_rhs_split.py | 106 ---- .../cases/preview_prefer_rhs_split.py.expect | 106 ---- ...t_skip_with_multiple_comments.options.json | 1 - ...line_format_skip_with_multiple_comments.py | 8 - ...rmat_skip_with_multiple_comments.py.expect | 8 - .../cases/preview_trailing_comma.options.json | 1 - .../black/cases/preview_trailing_comma.py | 24 - .../cases/preview_trailing_comma.py.expect | 28 - .../remove_newline_after_match.options.json | 1 - .../black/cases/remove_newline_after_match.py | 19 - .../remove_newline_after_match.py.expect | 13 - .../fixtures/black/conditional_expression.py | 67 --- .../black/conditional_expression.py.expect | 90 --- .../fixtures/black/miscellaneous/force_pyi.py | 30 - .../black/miscellaneous/force_pyi.py.expect | 32 -- .../test/fixtures/black/raw_docstring.py | 16 - .../fixtures/black/raw_docstring.py.expect | 14 - ...th_braces_and_square_brackets.options.json | 3 - ..._parens_with_braces_and_square_brackets.py | 141 ----- ..._with_braces_and_square_brackets.py.expect | 159 ----- .../test/fixtures/import_black_tests.py | 22 +- crates/ruff_python_formatter/src/options.rs | 22 +- ...ibility@cases__context_managers_39.py.snap | 341 ----------- ...es__context_managers_autodetect_39.py.snap | 80 --- ...es__preview_allow_empty_first_line.py.snap | 325 ----------- ..._empty_first_line_in_special_cases.py.snap | 217 ------- ..._docstring_no_string_normalization.py.snap | 67 --- ...tibility@cases__preview_form_feeds.py.snap | 457 --------------- ...ew_pattern_matching_trailing_comma.py.snap | 103 ---- ...@cases__preview_percent_precedence.py.snap | 98 ---- ...ty@cases__preview_prefer_rhs_split.py.snap | 353 ------------ ...format_skip_with_multiple_comments.py.snap | 62 -- ...mpatibility@conditional_expression.py.snap | 333 ----------- ...atibility@miscellaneous__force_pyi.py.snap | 179 ------ .../black_compatibility@raw_docstring.py.snap | 85 --- ...ns_with_braces_and_square_brackets.py.snap | 542 ------------------ ...@blank_line_before_class_docstring.py.snap | 2 +- .../tests/snapshots/format@docstring.py.snap | 10 +- .../format@docstring_code_examples.py.snap | 20 +- ...ormat@docstring_code_examples_crlf.py.snap | 2 +- ...g_code_examples_dynamic_line_width.py.snap | 8 +- .../format@docstring_tab_indentation.py.snap | 4 +- .../format@expression__bytes.py.snap | 4 +- .../format@expression__fstring.py.snap | 4 +- ..._join_implicit_concatenated_string.py.snap | 2 +- ...cit_concatenated_string_assignment.py.snap | 2 +- ...licit_concatenated_string_preserve.py.snap | 2 +- .../format@expression__string.py.snap | 4 +- ...rmat@fmt_on_off__fmt_off_docstring.py.snap | 4 +- .../format@fmt_on_off__indent.py.snap | 6 +- ...at@fmt_on_off__mixed_space_and_tab.py.snap | 6 +- .../format@notebook_docstring.py.snap | 4 +- .../tests/snapshots/format@preview.py.snap | 4 +- .../snapshots/format@quote_style.py.snap | 6 +- ...ormatting__docstring_code_examples.py.snap | 4 +- .../format@range_formatting__indent.py.snap | 6 +- .../format@range_formatting__stub.pyi.snap | 2 +- .../format@skip_magic_trailing_comma.py.snap | 4 +- ...ment__assignment_split_value_first.py.snap | 2 +- ...lank_line_after_nested_stub_class.pyi.snap | 2 +- ..._line_after_nested_stub_class_eof.pyi.snap | 2 +- .../tests/snapshots/format@tab_width.py.snap | 6 +- crates/ruff_workspace/src/options.rs | 30 +- docs/configuration.md | 8 +- 125 files changed, 168 insertions(+), 5488 deletions(-) create mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/context_managers_38.options.json create mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/context_managers_autodetect_38.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line_in_special_cases.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line_in_special_cases.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line_in_special_cases.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_async_stmts.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_async_stmts.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_async_stmts.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_38.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_38.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_38.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_39.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_39.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_39.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_310.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_310.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_310.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_311.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_311.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_311.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_38.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_38.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_38.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_39.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_39.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_39.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_docstring_no_string_normalization.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_docstring_no_string_normalization.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_docstring_no_string_normalization.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_dummy_implementations.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_dummy_implementations.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_dummy_implementations.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_form_feeds.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_form_feeds.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_form_feeds.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_no_blank_line_before_docstring.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_no_blank_line_before_docstring.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_no_blank_line_before_docstring.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_long.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_long.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_long.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_trailing_comma.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_trailing_comma.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_trailing_comma.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pep_572.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pep_572.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pep_572.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_percent_precedence.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_percent_precedence.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_percent_precedence.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_power_op_spacing.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_power_op_spacing.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_power_op_spacing.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_prefer_rhs_split.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_prefer_rhs_split.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_prefer_rhs_split.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_single_line_format_skip_with_multiple_comments.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_single_line_format_skip_with_multiple_comments.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_single_line_format_skip_with_multiple_comments.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_trailing_comma.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_trailing_comma.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_trailing_comma.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/remove_newline_after_match.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/remove_newline_after_match.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/remove_newline_after_match.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/conditional_expression.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/conditional_expression.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/miscellaneous/force_pyi.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/miscellaneous/force_pyi.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/raw_docstring.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/raw_docstring.py.expect delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/preview_hug_parens_with_braces_and_square_brackets.options.json delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/preview_hug_parens_with_braces_and_square_brackets.py delete mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/preview_hug_parens_with_braces_and_square_brackets.py.expect delete mode 100644 crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__context_managers_39.py.snap delete mode 100644 crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__context_managers_autodetect_39.py.snap delete mode 100644 crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_allow_empty_first_line.py.snap delete mode 100644 crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_allow_empty_first_line_in_special_cases.py.snap delete mode 100644 crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_docstring_no_string_normalization.py.snap delete mode 100644 crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_form_feeds.py.snap delete mode 100644 crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_pattern_matching_trailing_comma.py.snap delete mode 100644 crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_percent_precedence.py.snap delete mode 100644 crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_prefer_rhs_split.py.snap delete mode 100644 crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_single_line_format_skip_with_multiple_comments.py.snap delete mode 100644 crates/ruff_python_formatter/tests/snapshots/black_compatibility@conditional_expression.py.snap delete mode 100644 crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__force_pyi.py.snap delete mode 100644 crates/ruff_python_formatter/tests/snapshots/black_compatibility@raw_docstring.py.snap delete mode 100644 crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__preview_hug_parens_with_braces_and_square_brackets.py.snap diff --git a/README.md b/README.md index 846ef7fa8d1fa..c854682b50976 100644 --- a/README.md +++ b/README.md @@ -238,8 +238,8 @@ exclude = [ line-length = 88 indent-width = 4 -# Assume Python 3.8 -target-version = "py38" +# Assume Python 3.9 +target-version = "py39" [lint] # Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. diff --git a/crates/red_knot/src/target_version.rs b/crates/red_knot/src/target_version.rs index 7db3c514e890b..9827c5c40ee8d 100644 --- a/crates/red_knot/src/target_version.rs +++ b/crates/red_knot/src/target_version.rs @@ -46,3 +46,17 @@ impl From for red_knot_python_semantic::PythonVersion { } } } + +#[cfg(test)] +mod tests { + use crate::target_version::TargetVersion; + use red_knot_python_semantic::PythonVersion; + + #[test] + fn same_default_as_python_version() { + assert_eq!( + PythonVersion::from(TargetVersion::default()), + PythonVersion::default() + ); + } +} diff --git a/crates/red_knot_wasm/src/lib.rs b/crates/red_knot_wasm/src/lib.rs index 63b67240ad5db..abf19b404a3be 100644 --- a/crates/red_knot_wasm/src/lib.rs +++ b/crates/red_knot_wasm/src/lib.rs @@ -291,3 +291,17 @@ impl System for WasmSystem { fn not_found() -> std::io::Error { std::io::Error::new(std::io::ErrorKind::NotFound, "No such file or directory") } + +#[cfg(test)] +mod tests { + use crate::TargetVersion; + use red_knot_python_semantic::PythonVersion; + + #[test] + fn same_default_as_python_version() { + assert_eq!( + PythonVersion::from(TargetVersion::default()), + PythonVersion::default() + ); + } +} diff --git a/crates/ruff_linter/src/settings/types.rs b/crates/ruff_linter/src/settings/types.rs index e0f38391f5823..be53584c8c2b1 100644 --- a/crates/ruff_linter/src/settings/types.rs +++ b/crates/ruff_linter/src/settings/types.rs @@ -42,10 +42,10 @@ use crate::{display_settings, fs}; #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum PythonVersion { Py37, + Py38, // Make sure to also change the default for `ruff_python_formatter::PythonVersion` // when changing the default here. #[default] - Py38, Py39, Py310, Py311, @@ -68,6 +68,10 @@ impl PythonVersion { Self::Py313 } + pub const fn minimal_supported() -> Self { + Self::Py37 + } + pub const fn as_tuple(&self) -> (u8, u8) { match self { Self::Py37 => (3, 7), diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/context_managers_38.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/context_managers_38.options.json new file mode 100644 index 0000000000000..56ae457e6016c --- /dev/null +++ b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/context_managers_38.options.json @@ -0,0 +1 @@ +{"target_version": "py38"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/context_managers_autodetect_38.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/context_managers_autodetect_38.options.json new file mode 100644 index 0000000000000..56ae457e6016c --- /dev/null +++ b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/context_managers_autodetect_38.options.json @@ -0,0 +1 @@ +{"target_version": "py38"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line.options.json deleted file mode 100644 index ce7c52b163497..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line.options.json +++ /dev/null @@ -1 +0,0 @@ -{"preview": "enabled"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line.py deleted file mode 100644 index 44b54ba9d7aa5..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line.py +++ /dev/null @@ -1,82 +0,0 @@ -def foo(): - """ - Docstring - """ - - # Here we go - if x: - - # This is also now fine - a = 123 - - else: - # But not necessary - a = 123 - - if y: - - while True: - - """ - Long comment here - """ - a = 123 - - if z: - - for _ in range(100): - a = 123 - else: - - try: - - # this should be ok - a = 123 - except: - - """also this""" - a = 123 - - -def bar(): - - if x: - a = 123 - - -def baz(): - - # OK - if x: - a = 123 - -def quux(): - - new_line = here - - -class Cls: - - def method(self): - - pass - - -async def async_fn(): - - """Docstring.""" - - -@decorated -async def async_fn(): - - """Docstring.""" - - -def top_level( - a: int, - b: str, -) -> Whatever[Generic, Something]: - - def nested(x: int) -> int: - pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line.py.expect deleted file mode 100644 index 3e5bdea0f93e5..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line.py.expect +++ /dev/null @@ -1,81 +0,0 @@ -def foo(): - """ - Docstring - """ - - # Here we go - if x: - - # This is also now fine - a = 123 - - else: - # But not necessary - a = 123 - - if y: - - while True: - - """ - Long comment here - """ - a = 123 - - if z: - - for _ in range(100): - a = 123 - else: - - try: - - # this should be ok - a = 123 - except: - - """also this""" - a = 123 - - -def bar(): - - if x: - a = 123 - - -def baz(): - - # OK - if x: - a = 123 - - -def quux(): - - new_line = here - - -class Cls: - - def method(self): - - pass - - -async def async_fn(): - """Docstring.""" - - -@decorated -async def async_fn(): - """Docstring.""" - - -def top_level( - a: int, - b: str, -) -> Whatever[Generic, Something]: - - def nested(x: int) -> int: - pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line_in_special_cases.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line_in_special_cases.options.json deleted file mode 100644 index ce7c52b163497..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line_in_special_cases.options.json +++ /dev/null @@ -1 +0,0 @@ -{"preview": "enabled"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line_in_special_cases.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line_in_special_cases.py deleted file mode 100644 index 7cf2fc1b8c18d..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line_in_special_cases.py +++ /dev/null @@ -1,51 +0,0 @@ -def foo(): - """ - Docstring - """ - - # Here we go - if x: - - # This is also now fine - a = 123 - - else: - # But not necessary - a = 123 - - if y: - - while True: - - """ - Long comment here - """ - a = 123 - - if z: - - for _ in range(100): - a = 123 - else: - - try: - - # this should be ok - a = 123 - except: - - """also this""" - a = 123 - - -def bar(): - - if x: - a = 123 - - -def baz(): - - # OK - if x: - a = 123 diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line_in_special_cases.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line_in_special_cases.py.expect deleted file mode 100644 index 570a63b1d3f3c..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line_in_special_cases.py.expect +++ /dev/null @@ -1,51 +0,0 @@ -def foo(): - """ - Docstring - """ - - # Here we go - if x: - - # This is also now fine - a = 123 - - else: - # But not necessary - a = 123 - - if y: - - while True: - - """ - Long comment here - """ - a = 123 - - if z: - - for _ in range(100): - a = 123 - else: - - try: - - # this should be ok - a = 123 - except: - - """also this""" - a = 123 - - -def bar(): - - if x: - a = 123 - - -def baz(): - - # OK - if x: - a = 123 diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_async_stmts.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_async_stmts.options.json deleted file mode 100644 index ce7c52b163497..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_async_stmts.options.json +++ /dev/null @@ -1 +0,0 @@ -{"preview": "enabled"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_async_stmts.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_async_stmts.py deleted file mode 100644 index 88767abb88cc6..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_async_stmts.py +++ /dev/null @@ -1,11 +0,0 @@ -async def func() -> (int): - return 0 - - -@decorated -async def func() -> (int): - return 0 - - -async for (item) in async_iter: - pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_async_stmts.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_async_stmts.py.expect deleted file mode 100644 index 13423345b6386..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_async_stmts.py.expect +++ /dev/null @@ -1,11 +0,0 @@ -async def func() -> int: - return 0 - - -@decorated -async def func() -> int: - return 0 - - -async for item in async_iter: - pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_38.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_38.options.json deleted file mode 100644 index a3b0502b7c9f7..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_38.options.json +++ /dev/null @@ -1 +0,0 @@ -{"preview": "enabled", "target_version": "py38"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_38.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_38.py deleted file mode 100644 index 811be47176279..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_38.py +++ /dev/null @@ -1,31 +0,0 @@ -with \ - make_context_manager1() as cm1, \ - make_context_manager2() as cm2, \ - make_context_manager3() as cm3, \ - make_context_manager4() as cm4 \ -: - pass - - -with \ - make_context_manager1() as cm1, \ - make_context_manager2(), \ - make_context_manager3() as cm3, \ - make_context_manager4() \ -: - pass - - -with \ - new_new_new1() as cm1, \ - new_new_new2() \ -: - pass - - -with mock.patch.object( - self.my_runner, "first_method", autospec=True -) as mock_run_adb, mock.patch.object( - self.my_runner, "second_method", autospec=True, return_value="foo" -): - pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_38.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_38.py.expect deleted file mode 100644 index 5c0cdde0d29a5..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_38.py.expect +++ /dev/null @@ -1,18 +0,0 @@ -with make_context_manager1() as cm1, make_context_manager2() as cm2, make_context_manager3() as cm3, make_context_manager4() as cm4: - pass - - -with make_context_manager1() as cm1, make_context_manager2(), make_context_manager3() as cm3, make_context_manager4(): - pass - - -with new_new_new1() as cm1, new_new_new2(): - pass - - -with mock.patch.object( - self.my_runner, "first_method", autospec=True -) as mock_run_adb, mock.patch.object( - self.my_runner, "second_method", autospec=True, return_value="foo" -): - pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_39.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_39.options.json deleted file mode 100644 index 8bb726753bf76..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_39.options.json +++ /dev/null @@ -1 +0,0 @@ -{"preview": "enabled", "target_version": "py39"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_39.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_39.py deleted file mode 100644 index f0ae0053630a2..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_39.py +++ /dev/null @@ -1,84 +0,0 @@ -with \ - make_context_manager1() as cm1, \ - make_context_manager2() as cm2, \ - make_context_manager3() as cm3, \ - make_context_manager4() as cm4 \ -: - pass - - -# Leading comment -with \ - make_context_manager1() as cm1, \ - make_context_manager2(), \ - make_context_manager3() as cm3, \ - make_context_manager4() \ -: - pass - - -with \ - new_new_new1() as cm1, \ - new_new_new2() \ -: - pass - - -with ( - new_new_new1() as cm1, - new_new_new2() -): - pass - - -# Leading comment. -with ( - # First comment. - new_new_new1() as cm1, - # Second comment. - new_new_new2() - # Last comment. -): - pass - - -with \ - this_is_a_very_long_call(looong_arg1=looong_value1, looong_arg2=looong_value2) as cm1, \ - this_is_a_very_long_call(looong_arg1=looong_value1, looong_arg2=looong_value2, looong_arg3=looong_value3, looong_arg4=looong_value4) as cm2 \ -: - pass - - -with mock.patch.object( - self.my_runner, "first_method", autospec=True -) as mock_run_adb, mock.patch.object( - self.my_runner, "second_method", autospec=True, return_value="foo" -): - pass - - -with xxxxxxxx.some_kind_of_method( - some_argument=[ - "first", - "second", - "third", - ] -).another_method() as cmd: - pass - - -async def func(): - async with \ - make_context_manager1() as cm1, \ - make_context_manager2() as cm2, \ - make_context_manager3() as cm3, \ - make_context_manager4() as cm4 \ - : - pass - - async with some_function( - argument1, argument2, argument3="some_value" - ) as some_cm, some_other_function( - argument1, argument2, argument3="some_value" - ): - pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_39.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_39.py.expect deleted file mode 100644 index 1b8e86593390b..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_39.py.expect +++ /dev/null @@ -1,85 +0,0 @@ -with ( - make_context_manager1() as cm1, - make_context_manager2() as cm2, - make_context_manager3() as cm3, - make_context_manager4() as cm4, -): - pass - - -# Leading comment -with ( - make_context_manager1() as cm1, - make_context_manager2(), - make_context_manager3() as cm3, - make_context_manager4(), -): - pass - - -with new_new_new1() as cm1, new_new_new2(): - pass - - -with new_new_new1() as cm1, new_new_new2(): - pass - - -# Leading comment. -with ( - # First comment. - new_new_new1() as cm1, - # Second comment. - new_new_new2(), - # Last comment. -): - pass - - -with ( - this_is_a_very_long_call( - looong_arg1=looong_value1, looong_arg2=looong_value2 - ) as cm1, - this_is_a_very_long_call( - looong_arg1=looong_value1, - looong_arg2=looong_value2, - looong_arg3=looong_value3, - looong_arg4=looong_value4, - ) as cm2, -): - pass - - -with ( - mock.patch.object(self.my_runner, "first_method", autospec=True) as mock_run_adb, - mock.patch.object( - self.my_runner, "second_method", autospec=True, return_value="foo" - ), -): - pass - - -with xxxxxxxx.some_kind_of_method( - some_argument=[ - "first", - "second", - "third", - ] -).another_method() as cmd: - pass - - -async def func(): - async with ( - make_context_manager1() as cm1, - make_context_manager2() as cm2, - make_context_manager3() as cm3, - make_context_manager4() as cm4, - ): - pass - - async with ( - some_function(argument1, argument2, argument3="some_value") as some_cm, - some_other_function(argument1, argument2, argument3="some_value"), - ): - pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_310.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_310.options.json deleted file mode 100644 index 0aaaa152bc848..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_310.options.json +++ /dev/null @@ -1 +0,0 @@ -{"preview": "enabled", "target_version": "py310"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_310.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_310.py deleted file mode 100644 index 493ad2110867c..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_310.py +++ /dev/null @@ -1,15 +0,0 @@ -# This file uses pattern matching introduced in Python 3.10. - - -match http_code: - case 404: - print("Not found") - - -with \ - make_context_manager1() as cm1, \ - make_context_manager2() as cm2, \ - make_context_manager3() as cm3, \ - make_context_manager4() as cm4 \ -: - pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_310.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_310.py.expect deleted file mode 100644 index 4c35978000410..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_310.py.expect +++ /dev/null @@ -1,15 +0,0 @@ -# This file uses pattern matching introduced in Python 3.10. - - -match http_code: - case 404: - print("Not found") - - -with ( - make_context_manager1() as cm1, - make_context_manager2() as cm2, - make_context_manager3() as cm3, - make_context_manager4() as cm4, -): - pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_311.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_311.options.json deleted file mode 100644 index f1b92cd916c4f..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_311.options.json +++ /dev/null @@ -1 +0,0 @@ -{"preview": "enabled", "target_version": "py311"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_311.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_311.py deleted file mode 100644 index fb3fb65a31129..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_311.py +++ /dev/null @@ -1,16 +0,0 @@ -# This file uses except* clause in Python 3.11. - - -try: - some_call() -except* Error as e: - pass - - -with \ - make_context_manager1() as cm1, \ - make_context_manager2() as cm2, \ - make_context_manager3() as cm3, \ - make_context_manager4() as cm4 \ -: - pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_311.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_311.py.expect deleted file mode 100644 index b5ca9c0b1473e..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_311.py.expect +++ /dev/null @@ -1,16 +0,0 @@ -# This file uses except* clause in Python 3.11. - - -try: - some_call() -except* Error as e: - pass - - -with ( - make_context_manager1() as cm1, - make_context_manager2() as cm2, - make_context_manager3() as cm3, - make_context_manager4() as cm4, -): - pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_38.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_38.options.json deleted file mode 100644 index ce7c52b163497..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_38.options.json +++ /dev/null @@ -1 +0,0 @@ -{"preview": "enabled"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_38.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_38.py deleted file mode 100644 index f48fbe78e3709..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_38.py +++ /dev/null @@ -1,24 +0,0 @@ -# This file doesn't use any Python 3.9+ only grammars. - - -# Make sure parens around a single context manager don't get autodetected as -# Python 3.9+. -with (a): - pass - - -with \ - make_context_manager1() as cm1, \ - make_context_manager2() as cm2, \ - make_context_manager3() as cm3, \ - make_context_manager4() as cm4 \ -: - pass - - -with mock.patch.object( - self.my_runner, "first_method", autospec=True -) as mock_run_adb, mock.patch.object( - self.my_runner, "second_method", autospec=True, return_value="foo" -): - pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_38.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_38.py.expect deleted file mode 100644 index d43eb9f0917ca..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_38.py.expect +++ /dev/null @@ -1,19 +0,0 @@ -# This file doesn't use any Python 3.9+ only grammars. - - -# Make sure parens around a single context manager don't get autodetected as -# Python 3.9+. -with a: - pass - - -with make_context_manager1() as cm1, make_context_manager2() as cm2, make_context_manager3() as cm3, make_context_manager4() as cm4: - pass - - -with mock.patch.object( - self.my_runner, "first_method", autospec=True -) as mock_run_adb, mock.patch.object( - self.my_runner, "second_method", autospec=True, return_value="foo" -): - pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_39.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_39.options.json deleted file mode 100644 index 8bb726753bf76..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_39.options.json +++ /dev/null @@ -1 +0,0 @@ -{"preview": "enabled", "target_version": "py39"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_39.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_39.py deleted file mode 100644 index c69d3a72894b7..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_39.py +++ /dev/null @@ -1,17 +0,0 @@ -# This file uses parenthesized context managers introduced in Python 3.9. - - -with \ - make_context_manager1() as cm1, \ - make_context_manager2() as cm2, \ - make_context_manager3() as cm3, \ - make_context_manager4() as cm4 \ -: - pass - - -with ( - new_new_new1() as cm1, - new_new_new2() -): - pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_39.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_39.py.expect deleted file mode 100644 index ff6ce999175b2..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_context_managers_autodetect_39.py.expect +++ /dev/null @@ -1,14 +0,0 @@ -# This file uses parenthesized context managers introduced in Python 3.9. - - -with ( - make_context_manager1() as cm1, - make_context_manager2() as cm2, - make_context_manager3() as cm3, - make_context_manager4() as cm4, -): - pass - - -with new_new_new1() as cm1, new_new_new2(): - pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_docstring_no_string_normalization.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_docstring_no_string_normalization.options.json deleted file mode 100644 index ce7c52b163497..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_docstring_no_string_normalization.options.json +++ /dev/null @@ -1 +0,0 @@ -{"preview": "enabled"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_docstring_no_string_normalization.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_docstring_no_string_normalization.py deleted file mode 100644 index 338cc01d33e64..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_docstring_no_string_normalization.py +++ /dev/null @@ -1,10 +0,0 @@ -def do_not_touch_this_prefix(): - R"""There was a bug where docstring prefixes would be normalized even with -S.""" - - -def do_not_touch_this_prefix2(): - FR'There was a bug where docstring prefixes would be normalized even with -S.' - - -def do_not_touch_this_prefix3(): - u'''There was a bug where docstring prefixes would be normalized even with -S.''' diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_docstring_no_string_normalization.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_docstring_no_string_normalization.py.expect deleted file mode 100644 index 338cc01d33e64..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_docstring_no_string_normalization.py.expect +++ /dev/null @@ -1,10 +0,0 @@ -def do_not_touch_this_prefix(): - R"""There was a bug where docstring prefixes would be normalized even with -S.""" - - -def do_not_touch_this_prefix2(): - FR'There was a bug where docstring prefixes would be normalized even with -S.' - - -def do_not_touch_this_prefix3(): - u'''There was a bug where docstring prefixes would be normalized even with -S.''' diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_dummy_implementations.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_dummy_implementations.options.json deleted file mode 100644 index ce7c52b163497..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_dummy_implementations.options.json +++ /dev/null @@ -1 +0,0 @@ -{"preview": "enabled"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_dummy_implementations.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_dummy_implementations.py deleted file mode 100644 index 739359ee25bbc..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_dummy_implementations.py +++ /dev/null @@ -1,69 +0,0 @@ -from typing import NoReturn, Protocol, Union, overload - -class Empty: - ... - -def dummy(a): ... -async def other(b): ... - - -@overload -def a(arg: int) -> int: ... -@overload -def a(arg: str) -> str: ... -@overload -def a(arg: object) -> NoReturn: ... -def a(arg: Union[int, str, object]) -> Union[int, str]: - if not isinstance(arg, (int, str)): - raise TypeError - return arg - -class Proto(Protocol): - def foo(self, a: int) -> int: - ... - - def bar(self, b: str) -> str: ... - def baz(self, c: bytes) -> str: - ... - - -def dummy_two(): - ... -@dummy -def dummy_three(): - ... - -def dummy_four(): - ... - -@overload -def b(arg: int) -> int: ... - -@overload -def b(arg: str) -> str: ... -@overload -def b(arg: object) -> NoReturn: ... - -def b(arg: Union[int, str, object]) -> Union[int, str]: - if not isinstance(arg, (int, str)): - raise TypeError - return arg - -def has_comment(): - ... # still a dummy - -if some_condition: - ... - -if already_dummy: ... - -class AsyncCls: - async def async_method(self): - ... - -async def async_function(self): - ... - -@decorated -async def async_function(self): - ... diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_dummy_implementations.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_dummy_implementations.py.expect deleted file mode 100644 index 369e442152116..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_dummy_implementations.py.expect +++ /dev/null @@ -1,72 +0,0 @@ -from typing import NoReturn, Protocol, Union, overload - - -class Empty: ... - - -def dummy(a): ... -async def other(b): ... - - -@overload -def a(arg: int) -> int: ... -@overload -def a(arg: str) -> str: ... -@overload -def a(arg: object) -> NoReturn: ... -def a(arg: Union[int, str, object]) -> Union[int, str]: - if not isinstance(arg, (int, str)): - raise TypeError - return arg - - -class Proto(Protocol): - def foo(self, a: int) -> int: ... - - def bar(self, b: str) -> str: ... - def baz(self, c: bytes) -> str: ... - - -def dummy_two(): ... -@dummy -def dummy_three(): ... - - -def dummy_four(): ... - - -@overload -def b(arg: int) -> int: ... - - -@overload -def b(arg: str) -> str: ... -@overload -def b(arg: object) -> NoReturn: ... - - -def b(arg: Union[int, str, object]) -> Union[int, str]: - if not isinstance(arg, (int, str)): - raise TypeError - return arg - - -def has_comment(): ... # still a dummy - - -if some_condition: - ... - -if already_dummy: - ... - - -class AsyncCls: - async def async_method(self): ... - - -async def async_function(self): ... - - -@decorated -async def async_function(self): ... diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_form_feeds.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_form_feeds.options.json deleted file mode 100644 index ce7c52b163497..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_form_feeds.options.json +++ /dev/null @@ -1 +0,0 @@ -{"preview": "enabled"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_form_feeds.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_form_feeds.py deleted file mode 100644 index 42ba8fe243b29..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_form_feeds.py +++ /dev/null @@ -1,116 +0,0 @@ -# Warning! This file contains form feeds (ASCII 0x0C, often represented by \f or ^L). -# These may be invisible in your editor: ensure you can see them before making changes here. - -# There's one at the start that'll get stripped - -# Comment and statement processing is different enough that we'll test variations of both -# contexts here - -# - - -# - - -# - - - -# - - - -# - - - -# - - -# - - - -# - -# - -# - - \ -# -pass - -pass - - -pass - - -pass - - - -pass - - - -pass - - - -pass - - -pass - - - -pass - -pass - -pass - - -# form feed after a dedent -def foo(): - pass - -pass - - -# form feeds are prohibited inside blocks, or on a line with nonwhitespace - def bar( a = 1 ,b : bool = False ) : - - - pass - - -class Baz: - - def __init__(self): - pass - - - def something(self): - pass - - - -# -pass -pass # -a = 1 - # - pass - a = 1 - -a = [ - -] - -# as internal whitespace of a comment is allowed but why -"form feed literal in a string is okay " - -# form feeds at the very end get removed. diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_form_feeds.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_form_feeds.py.expect deleted file mode 100644 index 4ce3d2832bf84..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_form_feeds.py.expect +++ /dev/null @@ -1,103 +0,0 @@ -# Warning! This file contains form feeds (ASCII 0x0C, often represented by \f or ^L). -# These may be invisible in your editor: ensure you can see them before making changes here. - -# There's one at the start that'll get stripped - -# Comment and statement processing is different enough that we'll test variations of both -# contexts here - -# - - -# - - -# - - -# - - -# - - -# - - -# - - -# - -# - -# - -# -pass - -pass - - -pass - - -pass - - -pass - - -pass - - -pass - - -pass - - -pass - -pass - -pass - - -# form feed after a dedent -def foo(): - pass - - -pass - - -# form feeds are prohibited inside blocks, or on a line with nonwhitespace -def bar(a=1, b: bool = False): - - pass - - -class Baz: - - def __init__(self): - pass - - def something(self): - pass - - -# -pass -pass # -a = 1 -# -pass -a = 1 - -a = [] - -# as internal whitespace of a comment is allowed but why -"form feed literal in a string is okay " - -# form feeds at the very end get removed. diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_no_blank_line_before_docstring.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_no_blank_line_before_docstring.options.json deleted file mode 100644 index ce7c52b163497..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_no_blank_line_before_docstring.options.json +++ /dev/null @@ -1 +0,0 @@ -{"preview": "enabled"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_no_blank_line_before_docstring.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_no_blank_line_before_docstring.py deleted file mode 100644 index 56d361087d206..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_no_blank_line_before_docstring.py +++ /dev/null @@ -1,33 +0,0 @@ -def line_before_docstring(): - - """Please move me up""" - - -class LineBeforeDocstring: - - """Please move me up""" - - -class EvenIfThereIsAMethodAfter: - - """I'm the docstring""" - def method(self): - pass - - -class TwoLinesBeforeDocstring: - - - """I want to be treated the same as if I were closer""" - - -class MultilineDocstringsAsWell: - - """I'm so far - - and on so many lines... - """ - -class SingleQuotedDocstring: - - "I'm a docstring but I don't even get triple quotes." diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_no_blank_line_before_docstring.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_no_blank_line_before_docstring.py.expect deleted file mode 100644 index fa042f49338ff..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_no_blank_line_before_docstring.py.expect +++ /dev/null @@ -1,28 +0,0 @@ -def line_before_docstring(): - """Please move me up""" - - -class LineBeforeDocstring: - """Please move me up""" - - -class EvenIfThereIsAMethodAfter: - """I'm the docstring""" - - def method(self): - pass - - -class TwoLinesBeforeDocstring: - """I want to be treated the same as if I were closer""" - - -class MultilineDocstringsAsWell: - """I'm so far - - and on so many lines... - """ - - -class SingleQuotedDocstring: - "I'm a docstring but I don't even get triple quotes." diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_long.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_long.options.json deleted file mode 100644 index 0aaaa152bc848..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_long.options.json +++ /dev/null @@ -1 +0,0 @@ -{"preview": "enabled", "target_version": "py310"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_long.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_long.py deleted file mode 100644 index 98b6ac56a2048..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_long.py +++ /dev/null @@ -1,7 +0,0 @@ -match x: - case "abcd" | "abcd" | "abcd" : - pass - case "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd": - pass - case xxxxxxxxxxxxxxxxxxxxxxx: - pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_long.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_long.py.expect deleted file mode 100644 index c60e5770a7a41..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_long.py.expect +++ /dev/null @@ -1,23 +0,0 @@ -match x: - case "abcd" | "abcd" | "abcd": - pass - case ( - "abcd" - | "abcd" - | "abcd" - | "abcd" - | "abcd" - | "abcd" - | "abcd" - | "abcd" - | "abcd" - | "abcd" - | "abcd" - | "abcd" - | "abcd" - | "abcd" - | "abcd" - ): - pass - case xxxxxxxxxxxxxxxxxxxxxxx: - pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_trailing_comma.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_trailing_comma.options.json deleted file mode 100644 index 0aaaa152bc848..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_trailing_comma.options.json +++ /dev/null @@ -1 +0,0 @@ -{"preview": "enabled", "target_version": "py310"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_trailing_comma.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_trailing_comma.py deleted file mode 100644 index 002ceea330686..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_trailing_comma.py +++ /dev/null @@ -1,14 +0,0 @@ -match maybe, multiple: - case perhaps, 5: - pass - case perhaps, 6,: - pass - - -match more := (than, one), indeed,: - case _, (5, 6): - pass - case [[5], (6)], [7],: - pass - case _: - pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_trailing_comma.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_trailing_comma.py.expect deleted file mode 100644 index 6e8ef32f18157..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_trailing_comma.py.expect +++ /dev/null @@ -1,20 +0,0 @@ -match maybe, multiple: - case perhaps, 5: - pass - case ( - perhaps, - 6, - ): - pass - - -match more := (than, one), indeed,: - case _, (5, 6): - pass - case ( - [[5], (6)], - [7], - ): - pass - case _: - pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pep_572.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pep_572.options.json deleted file mode 100644 index ce7c52b163497..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pep_572.options.json +++ /dev/null @@ -1 +0,0 @@ -{"preview": "enabled"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pep_572.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pep_572.py deleted file mode 100644 index dff98530388cf..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pep_572.py +++ /dev/null @@ -1,2 +0,0 @@ -x[(a:=0):] -x[:(a:=0)] diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pep_572.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pep_572.py.expect deleted file mode 100644 index a976b8a318bbb..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pep_572.py.expect +++ /dev/null @@ -1,2 +0,0 @@ -x[(a := 0) :] -x[: (a := 0)] diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_percent_precedence.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_percent_precedence.options.json deleted file mode 100644 index ce7c52b163497..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_percent_precedence.options.json +++ /dev/null @@ -1 +0,0 @@ -{"preview": "enabled"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_percent_precedence.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_percent_precedence.py deleted file mode 100644 index ab71177d2e1d7..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_percent_precedence.py +++ /dev/null @@ -1,20 +0,0 @@ -("" % a) ** 2 -("" % a)[0] -("" % a)() -("" % a).b - -2 * ("" % a) -2 @ ("" % a) -2 / ("" % a) -2 // ("" % a) -2 % ("" % a) -+("" % a) -b + ("" % a) --("" % a) -b - ("" % a) -b + -("" % a) -~("" % a) -2 ** ("" % a) -await ("" % a) -b[("" % a)] -b(("" % a)) diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_percent_precedence.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_percent_precedence.py.expect deleted file mode 100644 index bd77adeeb7524..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_percent_precedence.py.expect +++ /dev/null @@ -1,20 +0,0 @@ -("" % a) ** 2 -("" % a)[0] -("" % a)() -("" % a).b - -2 * ("" % a) -2 @ ("" % a) -2 / ("" % a) -2 // ("" % a) -2 % ("" % a) -+("" % a) -b + "" % a --("" % a) -b - "" % a -b + -("" % a) -~("" % a) -2 ** ("" % a) -await ("" % a) -b[("" % a)] -b(("" % a)) diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_power_op_spacing.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_power_op_spacing.options.json deleted file mode 100644 index ce7c52b163497..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_power_op_spacing.options.json +++ /dev/null @@ -1 +0,0 @@ -{"preview": "enabled"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_power_op_spacing.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_power_op_spacing.py deleted file mode 100644 index af361012ea829..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_power_op_spacing.py +++ /dev/null @@ -1,11 +0,0 @@ -a = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1 -b = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1 -c = 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 -d = 1**1 ** 1**1 ** 1**1 ** 1**1 ** 1**1**1 ** 1 ** 1**1 ** 1**1**1**1**1 ** 1 ** 1**1**1 **1**1** 1 ** 1 ** 1 -e = 𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟 -f = 𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟 - -a = 1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0 -b = 1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0 -c = 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 -d = 1.0**1.0 ** 1.0**1.0 ** 1.0**1.0 ** 1.0**1.0 ** 1.0**1.0**1.0 ** 1.0 ** 1.0**1.0 ** 1.0**1.0**1.0 diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_power_op_spacing.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_power_op_spacing.py.expect deleted file mode 100644 index da8b91530b81d..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_power_op_spacing.py.expect +++ /dev/null @@ -1,83 +0,0 @@ -a = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1 -b = ( - 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 - ** 1 -) -c = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1 -d = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1 -e = 𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟 -f = ( - 𨉟 - ** 𨉟 - ** 𨉟 - ** 𨉟 - ** 𨉟 - ** 𨉟 - ** 𨉟 - ** 𨉟 - ** 𨉟 - ** 𨉟 - ** 𨉟 - ** 𨉟 - ** 𨉟 - ** 𨉟 - ** 𨉟 - ** 𨉟 - ** 𨉟 - ** 𨉟 - ** 𨉟 - ** 𨉟 - ** 𨉟 - ** 𨉟 -) - -a = 1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0 -b = ( - 1.0 - ** 1.0 - ** 1.0 - ** 1.0 - ** 1.0 - ** 1.0 - ** 1.0 - ** 1.0 - ** 1.0 - ** 1.0 - ** 1.0 - ** 1.0 - ** 1.0 - ** 1.0 - ** 1.0 - ** 1.0 - ** 1.0 - ** 1.0 -) -c = 1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0 -d = 1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0 diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_prefer_rhs_split.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_prefer_rhs_split.options.json deleted file mode 100644 index ce7c52b163497..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_prefer_rhs_split.options.json +++ /dev/null @@ -1 +0,0 @@ -{"preview": "enabled"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_prefer_rhs_split.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_prefer_rhs_split.py deleted file mode 100644 index f3d9fd672515c..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_prefer_rhs_split.py +++ /dev/null @@ -1,106 +0,0 @@ -first_item, second_item = ( - some_looooooooong_module.some_looooooooooooooong_function_name( - first_argument, second_argument, third_argument - ) -) - -some_dict["with_a_long_key"] = ( - some_looooooooong_module.some_looooooooooooooong_function_name( - first_argument, second_argument, third_argument - ) -) - -# Make sure it works when the RHS only has one pair of (optional) parens. -first_item, second_item = ( - some_looooooooong_module.SomeClass.some_looooooooooooooong_variable_name -) - -some_dict["with_a_long_key"] = ( - some_looooooooong_module.SomeClass.some_looooooooooooooong_variable_name -) - -# Make sure chaining assignments work. -first_item, second_item, third_item, forth_item = m["everything"] = ( - some_looooooooong_module.some_looooooooooooooong_function_name( - first_argument, second_argument, third_argument - ) -) - -# Make sure when the RHS's first split at the non-optional paren fits, -# we split there instead of the outer RHS optional paren. -first_item, second_item = some_looooooooong_module.some_loooooog_function_name( - first_argument, second_argument, third_argument -) - -( - first_item, - second_item, - third_item, - forth_item, - fifth_item, - last_item_very_loooooong, -) = some_looooooooong_module.some_looooooooooooooong_function_name( - first_argument, second_argument, third_argument -) - -( - first_item, - second_item, - third_item, - forth_item, - fifth_item, - last_item_very_loooooong, -) = everything = some_looooong_function_name( - first_argument, second_argument, third_argument -) - - -# Make sure unsplittable type ignore won't be moved. -some_kind_of_table[some_key] = util.some_function( # type: ignore # noqa: E501 - some_arg -).intersection(pk_cols) - -some_kind_of_table[ - some_key -] = lambda obj: obj.some_long_named_method() # type: ignore # noqa: E501 - -some_kind_of_table[ - some_key # type: ignore # noqa: E501 -] = lambda obj: obj.some_long_named_method() - - -# Make when when the left side of assignment plus the opening paren "... = (" is -# exactly line length limit + 1, it won't be split like that. -xxxxxxxxx_yyy_zzzzzzzz[ - xx.xxxxxx(x_yyy_zzzzzz.xxxxx[0]), x_yyy_zzzzzz.xxxxxx(xxxx=1) -] = 1 - - -# Right side of assignment contains un-nested pairs of inner parens. -some_kind_of_instance.some_kind_of_map[a_key] = ( - isinstance(some_var, SomeClass) - and table.something_and_something != table.something_else -) or ( - isinstance(some_other_var, BaseClass) and table.something != table.some_other_thing -) - -# Multiple targets -a = b = ( - ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc -) - -a = b = c = d = e = f = g = ( - hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh -) = i = j = ( - kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk -) - -a = ( - bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb -) = c - -a = ( - bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb -) = ( - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc -) = ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_prefer_rhs_split.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_prefer_rhs_split.py.expect deleted file mode 100644 index f3d9fd672515c..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_prefer_rhs_split.py.expect +++ /dev/null @@ -1,106 +0,0 @@ -first_item, second_item = ( - some_looooooooong_module.some_looooooooooooooong_function_name( - first_argument, second_argument, third_argument - ) -) - -some_dict["with_a_long_key"] = ( - some_looooooooong_module.some_looooooooooooooong_function_name( - first_argument, second_argument, third_argument - ) -) - -# Make sure it works when the RHS only has one pair of (optional) parens. -first_item, second_item = ( - some_looooooooong_module.SomeClass.some_looooooooooooooong_variable_name -) - -some_dict["with_a_long_key"] = ( - some_looooooooong_module.SomeClass.some_looooooooooooooong_variable_name -) - -# Make sure chaining assignments work. -first_item, second_item, third_item, forth_item = m["everything"] = ( - some_looooooooong_module.some_looooooooooooooong_function_name( - first_argument, second_argument, third_argument - ) -) - -# Make sure when the RHS's first split at the non-optional paren fits, -# we split there instead of the outer RHS optional paren. -first_item, second_item = some_looooooooong_module.some_loooooog_function_name( - first_argument, second_argument, third_argument -) - -( - first_item, - second_item, - third_item, - forth_item, - fifth_item, - last_item_very_loooooong, -) = some_looooooooong_module.some_looooooooooooooong_function_name( - first_argument, second_argument, third_argument -) - -( - first_item, - second_item, - third_item, - forth_item, - fifth_item, - last_item_very_loooooong, -) = everything = some_looooong_function_name( - first_argument, second_argument, third_argument -) - - -# Make sure unsplittable type ignore won't be moved. -some_kind_of_table[some_key] = util.some_function( # type: ignore # noqa: E501 - some_arg -).intersection(pk_cols) - -some_kind_of_table[ - some_key -] = lambda obj: obj.some_long_named_method() # type: ignore # noqa: E501 - -some_kind_of_table[ - some_key # type: ignore # noqa: E501 -] = lambda obj: obj.some_long_named_method() - - -# Make when when the left side of assignment plus the opening paren "... = (" is -# exactly line length limit + 1, it won't be split like that. -xxxxxxxxx_yyy_zzzzzzzz[ - xx.xxxxxx(x_yyy_zzzzzz.xxxxx[0]), x_yyy_zzzzzz.xxxxxx(xxxx=1) -] = 1 - - -# Right side of assignment contains un-nested pairs of inner parens. -some_kind_of_instance.some_kind_of_map[a_key] = ( - isinstance(some_var, SomeClass) - and table.something_and_something != table.something_else -) or ( - isinstance(some_other_var, BaseClass) and table.something != table.some_other_thing -) - -# Multiple targets -a = b = ( - ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc -) - -a = b = c = d = e = f = g = ( - hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh -) = i = j = ( - kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk -) - -a = ( - bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb -) = c - -a = ( - bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb -) = ( - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc -) = ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_single_line_format_skip_with_multiple_comments.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_single_line_format_skip_with_multiple_comments.options.json deleted file mode 100644 index ce7c52b163497..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_single_line_format_skip_with_multiple_comments.options.json +++ /dev/null @@ -1 +0,0 @@ -{"preview": "enabled"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_single_line_format_skip_with_multiple_comments.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_single_line_format_skip_with_multiple_comments.py deleted file mode 100644 index 812febcf2a19f..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_single_line_format_skip_with_multiple_comments.py +++ /dev/null @@ -1,8 +0,0 @@ -foo = 123 # fmt: skip # noqa: E501 # pylint -bar = ( - 123 , - ( 1 + 5 ) # pylint # fmt:skip -) -baz = "a" + "b" # pylint; fmt: skip; noqa: E501 -skip_will_not_work = "a" + "b" # pylint fmt:skip -skip_will_not_work2 = "a" + "b" # some text; fmt:skip happens to be part of it diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_single_line_format_skip_with_multiple_comments.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_single_line_format_skip_with_multiple_comments.py.expect deleted file mode 100644 index d799b0c790e27..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_single_line_format_skip_with_multiple_comments.py.expect +++ /dev/null @@ -1,8 +0,0 @@ -foo = 123 # fmt: skip # noqa: E501 # pylint -bar = ( - 123 , - ( 1 + 5 ) # pylint # fmt:skip -) -baz = "a" + "b" # pylint; fmt: skip; noqa: E501 -skip_will_not_work = "a" + "b" # pylint fmt:skip -skip_will_not_work2 = "a" + "b" # some text; fmt:skip happens to be part of it diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_trailing_comma.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_trailing_comma.options.json deleted file mode 100644 index ce7c52b163497..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_trailing_comma.options.json +++ /dev/null @@ -1 +0,0 @@ -{"preview": "enabled"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_trailing_comma.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_trailing_comma.py deleted file mode 100644 index 24c53091b9002..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_trailing_comma.py +++ /dev/null @@ -1,24 +0,0 @@ -e = { - "a": fun(msg, "ts"), - "longggggggggggggggid": ..., - "longgggggggggggggggggggkey": ..., "created": ... - # "longkey": ... -} -f = [ - arg1, - arg2, - arg3, arg4 - # comment -] -g = ( - arg1, - arg2, - arg3, arg4 - # comment -) -h = { - arg1, - arg2, - arg3, arg4 - # comment -} diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_trailing_comma.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_trailing_comma.py.expect deleted file mode 100644 index 1b2bafa0287ec..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_trailing_comma.py.expect +++ /dev/null @@ -1,28 +0,0 @@ -e = { - "a": fun(msg, "ts"), - "longggggggggggggggid": ..., - "longgggggggggggggggggggkey": ..., - "created": ..., - # "longkey": ... -} -f = [ - arg1, - arg2, - arg3, - arg4, - # comment -] -g = ( - arg1, - arg2, - arg3, - arg4, - # comment -) -h = { - arg1, - arg2, - arg3, - arg4, - # comment -} diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/remove_newline_after_match.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/remove_newline_after_match.options.json deleted file mode 100644 index 60044b9854d9b..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/remove_newline_after_match.options.json +++ /dev/null @@ -1 +0,0 @@ -{"target_version": "py310"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/remove_newline_after_match.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/remove_newline_after_match.py deleted file mode 100644 index 629b645fce34f..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/remove_newline_after_match.py +++ /dev/null @@ -1,19 +0,0 @@ -def http_status(status): - - match status: - - case 400: - - return "Bad request" - - case 401: - - return "Unauthorized" - - case 403: - - return "Forbidden" - - case 404: - - return "Not found" diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/remove_newline_after_match.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/remove_newline_after_match.py.expect deleted file mode 100644 index 735169ef523cf..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/remove_newline_after_match.py.expect +++ /dev/null @@ -1,13 +0,0 @@ -def http_status(status): - match status: - case 400: - return "Bad request" - - case 401: - return "Unauthorized" - - case 403: - return "Forbidden" - - case 404: - return "Not found" diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/conditional_expression.py b/crates/ruff_python_formatter/resources/test/fixtures/black/conditional_expression.py deleted file mode 100644 index bbe56623c6107..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/conditional_expression.py +++ /dev/null @@ -1,67 +0,0 @@ -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, - baz="hello, this is a another value", -) - -multiline_kwargs_indented = 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, - baz="hello, this is a another value", -) - -imploding_kwargs = my_function( - foo="test, this is a sample value", - bar=a - if foo - else b, - baz="hello, this is a another value", -) - -imploding_line = ( - 1 - if 1 + 1 == 2 - else 0 -) - -exploding_line = "hello this is a slightly long string" if some_long_value_name_foo_bar_baz else "this one is a little shorter" - -positional_argument_test(some_long_value_name_foo_bar_baz if some_boolean_variable else some_fallback_value_foo_bar_baz) - -def weird_default_argument(x=some_long_value_name_foo_bar_baz - if SOME_CONSTANT - else some_fallback_value_foo_bar_baz): - pass - -nested = "hello this is a slightly long string" if (some_long_value_name_foo_bar_baz if - nesting_test_expressions else some_fallback_value_foo_bar_baz) \ - else "this one is a little shorter" - -generator_expression = ( - some_long_value_name_foo_bar_baz if some_boolean_variable else some_fallback_value_foo_bar_baz for some_boolean_variable in some_iterable -) - - -def limit_offset_sql(self, low_mark, high_mark): - """Return LIMIT/OFFSET SQL clause.""" - limit, offset = self._get_limit_offset_params(low_mark, high_mark) - return " ".join( - sql - for sql in ( - "LIMIT %d" % limit if limit else None, - ("OFFSET %d" % offset) if offset else None, - ) - if sql - ) - - -def something(): - clone._iterable_class = ( - NamedValuesListIterable - if named - else FlatValuesListIterable - if flat - else ValuesListIterable - ) diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/conditional_expression.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/conditional_expression.py.expect deleted file mode 100644 index 122ea7860dea7..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/conditional_expression.py.expect +++ /dev/null @@ -1,90 +0,0 @@ -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 - ), - baz="hello, this is a another value", -) - -multiline_kwargs_indented = 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 - ), - baz="hello, this is a another value", -) - -imploding_kwargs = my_function( - foo="test, this is a sample value", - bar=a if foo else b, - baz="hello, this is a another value", -) - -imploding_line = 1 if 1 + 1 == 2 else 0 - -exploding_line = ( - "hello this is a slightly long string" - if some_long_value_name_foo_bar_baz - else "this one is a little shorter" -) - -positional_argument_test( - some_long_value_name_foo_bar_baz - if some_boolean_variable - else some_fallback_value_foo_bar_baz -) - - -def weird_default_argument( - x=( - some_long_value_name_foo_bar_baz - if SOME_CONSTANT - else some_fallback_value_foo_bar_baz - ), -): - pass - - -nested = ( - "hello this is a slightly long string" - if ( - some_long_value_name_foo_bar_baz - if nesting_test_expressions - else some_fallback_value_foo_bar_baz - ) - else "this one is a little shorter" -) - -generator_expression = ( - ( - some_long_value_name_foo_bar_baz - if some_boolean_variable - else some_fallback_value_foo_bar_baz - ) - for some_boolean_variable in some_iterable -) - - -def limit_offset_sql(self, low_mark, high_mark): - """Return LIMIT/OFFSET SQL clause.""" - limit, offset = self._get_limit_offset_params(low_mark, high_mark) - return " ".join( - sql - for sql in ( - "LIMIT %d" % limit if limit else None, - ("OFFSET %d" % offset) if offset else None, - ) - if sql - ) - - -def something(): - clone._iterable_class = ( - NamedValuesListIterable - if named - else FlatValuesListIterable if flat else ValuesListIterable - ) diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/miscellaneous/force_pyi.py b/crates/ruff_python_formatter/resources/test/fixtures/black/miscellaneous/force_pyi.py deleted file mode 100644 index 9c8c40cc96239..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/miscellaneous/force_pyi.py +++ /dev/null @@ -1,30 +0,0 @@ -from typing import Union - -@bird -def zoo(): ... - -class A: ... -@bar -class B: - def BMethod(self) -> None: ... - @overload - def BMethod(self, arg : List[str]) -> None: ... - -class C: ... -@hmm -class D: ... -class E: ... - -@baz -def foo() -> None: - ... - -class F (A , C): ... -def spam() -> None: ... - -@overload -def spam(arg: str) -> str: ... - -var : int = 1 - -def eggs() -> Union[str, int]: ... diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/miscellaneous/force_pyi.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/miscellaneous/force_pyi.py.expect deleted file mode 100644 index 4349ba0a53b5b..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/miscellaneous/force_pyi.py.expect +++ /dev/null @@ -1,32 +0,0 @@ -from typing import Union - -@bird -def zoo(): ... - -class A: ... - -@bar -class B: - def BMethod(self) -> None: ... - @overload - def BMethod(self, arg: List[str]) -> None: ... - -class C: ... - -@hmm -class D: ... - -class E: ... - -@baz -def foo() -> None: ... - -class F(A, C): ... - -def spam() -> None: ... -@overload -def spam(arg: str) -> str: ... - -var: int = 1 - -def eggs() -> Union[str, int]: ... diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/raw_docstring.py b/crates/ruff_python_formatter/resources/test/fixtures/black/raw_docstring.py deleted file mode 100644 index bfde79202aade..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/raw_docstring.py +++ /dev/null @@ -1,16 +0,0 @@ -# flags: --preview --skip-string-normalization -class C: - - r"""Raw""" - -def f(): - - r"""Raw""" - -class SingleQuotes: - - - r'''Raw''' - -class UpperCaseR: - R"""Raw""" diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/raw_docstring.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/raw_docstring.py.expect deleted file mode 100644 index 5be480f7f0e89..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/raw_docstring.py.expect +++ /dev/null @@ -1,14 +0,0 @@ -class C: - r"""Raw""" - - -def f(): - r"""Raw""" - - -class SingleQuotes: - r'''Raw''' - - -class UpperCaseR: - R"""Raw""" diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/preview_hug_parens_with_braces_and_square_brackets.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/preview_hug_parens_with_braces_and_square_brackets.options.json deleted file mode 100644 index c106a9c8f36ea..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/preview_hug_parens_with_braces_and_square_brackets.options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "preview": "enabled" -} diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/preview_hug_parens_with_braces_and_square_brackets.py b/crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/preview_hug_parens_with_braces_and_square_brackets.py deleted file mode 100644 index eff37f23c008b..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/preview_hug_parens_with_braces_and_square_brackets.py +++ /dev/null @@ -1,141 +0,0 @@ -def foo_brackets(request): - return JsonResponse( - { - "var_1": foo, - "var_2": bar, - } - ) - -def foo_square_brackets(request): - return JsonResponse( - [ - "var_1", - "var_2", - ] - ) - -func({"a": 37, "b": 42, "c": 927, "aaaaaaaaaaaaaaaaaaaaaaaaa": 11111111111111111111111111111111111111111}) - -func(["random_string_number_one","random_string_number_two","random_string_number_three","random_string_number_four"]) - -func( - { - # expand me - 'a':37, - 'b':42, - 'c':927 - } -) - -func( - [ - 'a', - 'b', - 'c', - ] -) - -func( - [ - 'a', - 'b', - 'c', - ], -) - -func( # a - [ # b - "c", # c - "d", # d - "e", # e - ] # f -) # g - -func( # a - { # b - "c": 1, # c - "d": 2, # d - "e": 3, # e - } # f -) # g - -func( - # preserve me - [ - "c", - "d", - "e", - ] -) - -func( - [ # preserve me but hug brackets - "c", - "d", - "e", - ] -) - -func( - [ - # preserve me but hug brackets - "c", - "d", - "e", - ] -) - -func( - [ - "c", - # preserve me but hug brackets - "d", - "e", - ] -) - -func( - [ - "c", - "d", - "e", - # preserve me but hug brackets - ] -) - -func( - [ - "c", - "d", - "e", - ] # preserve me but hug brackets -) - -func( - [ - "c", - "d", - "e", - ] - # preserve me -) - -func([x for x in "short line"]) -func([x for x in "long line long line long line long line long line long line long line"]) -func([x for x in [x for x in "long line long line long line long line long line long line long line"]]) - -func({"short line"}) -func({"long line", "long long line", "long long long line", "long long long long line", "long long long long long line"}) -func({{"long line", "long long line", "long long long line", "long long long long line", "long long long long long line"}}) - -foooooooooooooooooooo( - [{c: n + 1 for c in range(256)} for n in range(100)] + [{}], {size} -) - -baaaaaaaaaaaaar( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], {x}, "a string", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] -) - -foo(*["long long long long long line", "long long long long long line", "long long long long long line"]) - -foo(*[str(i) for i in range(100000000000000000000000000000000000000000000000000000000000)]) diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/preview_hug_parens_with_braces_and_square_brackets.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/preview_hug_parens_with_braces_and_square_brackets.py.expect deleted file mode 100644 index 963fb7c4040a4..0000000000000 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/preview_hug_parens_with_braces_and_square_brackets.py.expect +++ /dev/null @@ -1,159 +0,0 @@ -def foo_brackets(request): - return JsonResponse({ - "var_1": foo, - "var_2": bar, - }) - - -def foo_square_brackets(request): - return JsonResponse([ - "var_1", - "var_2", - ]) - - -func({ - "a": 37, - "b": 42, - "c": 927, - "aaaaaaaaaaaaaaaaaaaaaaaaa": 11111111111111111111111111111111111111111, -}) - -func([ - "random_string_number_one", - "random_string_number_two", - "random_string_number_three", - "random_string_number_four", -]) - -func({ - # expand me - "a": 37, - "b": 42, - "c": 927, -}) - -func([ - "a", - "b", - "c", -]) - -func( - [ - "a", - "b", - "c", - ], -) - -func([ # a # b - "c", # c - "d", # d - "e", # e -]) # f # g - -func({ # a # b - "c": 1, # c - "d": 2, # d - "e": 3, # e -}) # f # g - -func( - # preserve me - [ - "c", - "d", - "e", - ] -) - -func([ # preserve me but hug brackets - "c", - "d", - "e", -]) - -func([ - # preserve me but hug brackets - "c", - "d", - "e", -]) - -func([ - "c", - # preserve me but hug brackets - "d", - "e", -]) - -func([ - "c", - "d", - "e", - # preserve me but hug brackets -]) - -func([ - "c", - "d", - "e", -]) # preserve me but hug brackets - -func( - [ - "c", - "d", - "e", - ] - # preserve me -) - -func([x for x in "short line"]) -func([ - x for x in "long line long line long line long line long line long line long line" -]) -func([ - x - for x in [ - x - for x in "long line long line long line long line long line long line long line" - ] -]) - -func({"short line"}) -func({ - "long line", - "long long line", - "long long long line", - "long long long long line", - "long long long long long line", -}) -func({ - { - "long line", - "long long line", - "long long long line", - "long long long long line", - "long long long long long line", - } -}) - -foooooooooooooooooooo( - [{c: n + 1 for c in range(256)} for n in range(100)] + [{}], {size} -) - -baaaaaaaaaaaaar( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], {x}, "a string", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] -) - -foo(*[ - "long long long long long line", - "long long long long long line", - "long long long long long line", -]) - -foo(*[ - str(i) for i in range(100000000000000000000000000000000000000000000000000000000000) -]) diff --git a/crates/ruff_python_formatter/resources/test/fixtures/import_black_tests.py b/crates/ruff_python_formatter/resources/test/fixtures/import_black_tests.py index b658b5807332d..c55810a16972b 100755 --- a/crates/ruff_python_formatter/resources/test/fixtures/import_black_tests.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/import_black_tests.py @@ -35,12 +35,12 @@ def import_fixture(fixture: Path, fixture_set: str): # If there's no output marker, treat the whole file as already pre-formatted expected = input - options = {} + black_options = {} extension = "py" if flags: if "--preview" in flags or "--unstable" in flags: - options["preview"] = "enabled" + black_options["preview"] = "enabled" if "--pyi" in flags: extension = "pyi" @@ -53,21 +53,23 @@ def import_fixture(fixture: Path, fixture_set: str): [_, length_and_rest] = flags.split("--line-length=", 1) length = length_and_rest.split(" ", 1)[0] length = int(length) - options["line_width"] = 1 if length == 0 else length + black_options["line_width"] = 1 if length == 0 else length if "--minimum-version=" in flags: [_, version] = flags.split("--minimum-version=", 1) version = version.split(" ", 1)[0] # Convert 3.10 to py310 - options["target_version"] = f"py{version.strip().replace('.', '')}" + black_options["target_version"] = f"py{version.strip().replace('.', '')}" if "--skip-magic-trailing-comma" in flags: - options["magic_trailing_comma"] = "ignore" + black_options["magic_trailing_comma"] = "ignore" fixture_path = output_directory.joinpath(fixture.name).with_suffix(f".{extension}") expect_path = fixture_path.with_suffix(f".{extension}.expect") options_path = fixture_path.with_suffix(".options.json") + options = OPTIONS_OVERRIDES.get(fixture.name, black_options) + if len(options) > 0: if extension == "pyi": options["source_type"] = "Stub" @@ -109,6 +111,16 @@ def import_fixture(fixture: Path, fixture_set: str): "line_ranges_outside_source.py", ] +# Specs for which to override the formatter options +OPTIONS_OVERRIDES = { + "context_managers_38.py": { + "target_version": "py38" + }, + "context_managers_autodetect_38.py" : { + "target_version": "py38" + } +} + def import_fixtures(black_dir: str): """Imports all the black fixtures""" diff --git a/crates/ruff_python_formatter/src/options.rs b/crates/ruff_python_formatter/src/options.rs index 541bac549f5cd..790bcfe0f35c8 100644 --- a/crates/ruff_python_formatter/src/options.rs +++ b/crates/ruff_python_formatter/src/options.rs @@ -457,10 +457,10 @@ where #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum PythonVersion { Py37, + Py38, // Make sure to also change the default for `ruff_linter::settings::types::PythonVersion` // when changing the default here. #[default] - Py38, Py39, Py310, Py311, @@ -475,4 +475,24 @@ impl PythonVersion { pub fn supports_pep_701(self) -> bool { self >= Self::Py312 } + + pub fn as_tuple(self) -> (u8, u8) { + match self { + Self::Py37 => (3, 7), + Self::Py38 => (3, 8), + Self::Py39 => (3, 9), + Self::Py310 => (3, 10), + Self::Py311 => (3, 11), + Self::Py312 => (3, 12), + Self::Py313 => (3, 13), + } + } + + pub fn latest() -> Self { + Self::Py313 + } + + pub fn minimal_supported() -> Self { + Self::Py37 + } } diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__context_managers_39.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__context_managers_39.py.snap deleted file mode 100644 index c6ad245a3a870..0000000000000 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__context_managers_39.py.snap +++ /dev/null @@ -1,341 +0,0 @@ ---- -source: crates/ruff_python_formatter/tests/fixtures.rs -input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/context_managers_39.py -snapshot_kind: text ---- -## Input - -```python -with \ - make_context_manager1() as cm1, \ - make_context_manager2() as cm2, \ - make_context_manager3() as cm3, \ - make_context_manager4() as cm4 \ -: - pass - - -# Leading comment -with \ - make_context_manager1() as cm1, \ - make_context_manager2(), \ - make_context_manager3() as cm3, \ - make_context_manager4() \ -: - pass - - -with \ - new_new_new1() as cm1, \ - new_new_new2() \ -: - pass - - -with ( - new_new_new1() as cm1, - new_new_new2() -): - pass - - -# Leading comment. -with ( - # First comment. - new_new_new1() as cm1, - # Second comment. - new_new_new2() - # Last comment. -): - pass - - -with \ - this_is_a_very_long_call(looong_arg1=looong_value1, looong_arg2=looong_value2) as cm1, \ - this_is_a_very_long_call(looong_arg1=looong_value1, looong_arg2=looong_value2, looong_arg3=looong_value3, looong_arg4=looong_value4) as cm2 \ -: - pass - - -with mock.patch.object( - self.my_runner, "first_method", autospec=True -) as mock_run_adb, mock.patch.object( - self.my_runner, "second_method", autospec=True, return_value="foo" -): - pass - - -with xxxxxxxx.some_kind_of_method( - some_argument=[ - "first", - "second", - "third", - ] -).another_method() as cmd: - pass - - -async def func(): - async with \ - make_context_manager1() as cm1, \ - make_context_manager2() as cm2, \ - make_context_manager3() as cm3, \ - make_context_manager4() as cm4 \ - : - pass - - async with some_function( - argument1, argument2, argument3="some_value" - ) as some_cm, some_other_function( - argument1, argument2, argument3="some_value" - ): - pass -``` - -## Black Differences - -```diff ---- Black -+++ Ruff -@@ -1,19 +1,9 @@ --with ( -- make_context_manager1() as cm1, -- make_context_manager2() as cm2, -- make_context_manager3() as cm3, -- make_context_manager4() as cm4, --): -+with make_context_manager1() as cm1, make_context_manager2() as cm2, make_context_manager3() as cm3, make_context_manager4() as cm4: - pass - - - # Leading comment --with ( -- make_context_manager1() as cm1, -- make_context_manager2(), -- make_context_manager3() as cm3, -- make_context_manager4(), --): -+with make_context_manager1() as cm1, make_context_manager2(), make_context_manager3() as cm3, make_context_manager4(): - pass - - -@@ -36,25 +26,21 @@ - pass - - --with ( -- this_is_a_very_long_call( -- looong_arg1=looong_value1, looong_arg2=looong_value2 -- ) as cm1, -- this_is_a_very_long_call( -- looong_arg1=looong_value1, -- looong_arg2=looong_value2, -- looong_arg3=looong_value3, -- looong_arg4=looong_value4, -- ) as cm2, --): -+with this_is_a_very_long_call( -+ looong_arg1=looong_value1, looong_arg2=looong_value2 -+) as cm1, this_is_a_very_long_call( -+ looong_arg1=looong_value1, -+ looong_arg2=looong_value2, -+ looong_arg3=looong_value3, -+ looong_arg4=looong_value4, -+) as cm2: - pass - - --with ( -- mock.patch.object(self.my_runner, "first_method", autospec=True) as mock_run_adb, -- mock.patch.object( -- self.my_runner, "second_method", autospec=True, return_value="foo" -- ), -+with mock.patch.object( -+ self.my_runner, "first_method", autospec=True -+) as mock_run_adb, mock.patch.object( -+ self.my_runner, "second_method", autospec=True, return_value="foo" - ): - pass - -@@ -70,16 +56,10 @@ - - - async def func(): -- async with ( -- make_context_manager1() as cm1, -- make_context_manager2() as cm2, -- make_context_manager3() as cm3, -- make_context_manager4() as cm4, -- ): -+ async with make_context_manager1() as cm1, make_context_manager2() as cm2, make_context_manager3() as cm3, make_context_manager4() as cm4: - pass - -- async with ( -- some_function(argument1, argument2, argument3="some_value") as some_cm, -- some_other_function(argument1, argument2, argument3="some_value"), -- ): -+ async with some_function( -+ argument1, argument2, argument3="some_value" -+ ) as some_cm, some_other_function(argument1, argument2, argument3="some_value"): - pass -``` - -## Ruff Output - -```python -with make_context_manager1() as cm1, make_context_manager2() as cm2, make_context_manager3() as cm3, make_context_manager4() as cm4: - pass - - -# Leading comment -with make_context_manager1() as cm1, make_context_manager2(), make_context_manager3() as cm3, make_context_manager4(): - pass - - -with new_new_new1() as cm1, new_new_new2(): - pass - - -with new_new_new1() as cm1, new_new_new2(): - pass - - -# Leading comment. -with ( - # First comment. - new_new_new1() as cm1, - # Second comment. - new_new_new2(), - # Last comment. -): - pass - - -with this_is_a_very_long_call( - looong_arg1=looong_value1, looong_arg2=looong_value2 -) as cm1, this_is_a_very_long_call( - looong_arg1=looong_value1, - looong_arg2=looong_value2, - looong_arg3=looong_value3, - looong_arg4=looong_value4, -) as cm2: - pass - - -with mock.patch.object( - self.my_runner, "first_method", autospec=True -) as mock_run_adb, mock.patch.object( - self.my_runner, "second_method", autospec=True, return_value="foo" -): - pass - - -with xxxxxxxx.some_kind_of_method( - some_argument=[ - "first", - "second", - "third", - ] -).another_method() as cmd: - pass - - -async def func(): - async with make_context_manager1() as cm1, make_context_manager2() as cm2, make_context_manager3() as cm3, make_context_manager4() as cm4: - pass - - async with some_function( - argument1, argument2, argument3="some_value" - ) as some_cm, some_other_function(argument1, argument2, argument3="some_value"): - pass -``` - -## Black Output - -```python -with ( - make_context_manager1() as cm1, - make_context_manager2() as cm2, - make_context_manager3() as cm3, - make_context_manager4() as cm4, -): - pass - - -# Leading comment -with ( - make_context_manager1() as cm1, - make_context_manager2(), - make_context_manager3() as cm3, - make_context_manager4(), -): - pass - - -with new_new_new1() as cm1, new_new_new2(): - pass - - -with new_new_new1() as cm1, new_new_new2(): - pass - - -# Leading comment. -with ( - # First comment. - new_new_new1() as cm1, - # Second comment. - new_new_new2(), - # Last comment. -): - pass - - -with ( - this_is_a_very_long_call( - looong_arg1=looong_value1, looong_arg2=looong_value2 - ) as cm1, - this_is_a_very_long_call( - looong_arg1=looong_value1, - looong_arg2=looong_value2, - looong_arg3=looong_value3, - looong_arg4=looong_value4, - ) as cm2, -): - pass - - -with ( - mock.patch.object(self.my_runner, "first_method", autospec=True) as mock_run_adb, - mock.patch.object( - self.my_runner, "second_method", autospec=True, return_value="foo" - ), -): - pass - - -with xxxxxxxx.some_kind_of_method( - some_argument=[ - "first", - "second", - "third", - ] -).another_method() as cmd: - pass - - -async def func(): - async with ( - make_context_manager1() as cm1, - make_context_manager2() as cm2, - make_context_manager3() as cm3, - make_context_manager4() as cm4, - ): - pass - - async with ( - some_function(argument1, argument2, argument3="some_value") as some_cm, - some_other_function(argument1, argument2, argument3="some_value"), - ): - pass -``` diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__context_managers_autodetect_39.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__context_managers_autodetect_39.py.snap deleted file mode 100644 index cd8e0e64eb3c7..0000000000000 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__context_managers_autodetect_39.py.snap +++ /dev/null @@ -1,80 +0,0 @@ ---- -source: crates/ruff_python_formatter/tests/fixtures.rs -input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/context_managers_autodetect_39.py -snapshot_kind: text ---- -## Input - -```python -# This file uses parenthesized context managers introduced in Python 3.9. - - -with \ - make_context_manager1() as cm1, \ - make_context_manager2() as cm2, \ - make_context_manager3() as cm3, \ - make_context_manager4() as cm4 \ -: - pass - - -with ( - new_new_new1() as cm1, - new_new_new2() -): - pass -``` - -## Black Differences - -```diff ---- Black -+++ Ruff -@@ -1,12 +1,7 @@ - # This file uses parenthesized context managers introduced in Python 3.9. - - --with ( -- make_context_manager1() as cm1, -- make_context_manager2() as cm2, -- make_context_manager3() as cm3, -- make_context_manager4() as cm4, --): -+with make_context_manager1() as cm1, make_context_manager2() as cm2, make_context_manager3() as cm3, make_context_manager4() as cm4: - pass - - -``` - -## Ruff Output - -```python -# This file uses parenthesized context managers introduced in Python 3.9. - - -with make_context_manager1() as cm1, make_context_manager2() as cm2, make_context_manager3() as cm3, make_context_manager4() as cm4: - pass - - -with new_new_new1() as cm1, new_new_new2(): - pass -``` - -## Black Output - -```python -# This file uses parenthesized context managers introduced in Python 3.9. - - -with ( - make_context_manager1() as cm1, - make_context_manager2() as cm2, - make_context_manager3() as cm3, - make_context_manager4() as cm4, -): - pass - - -with new_new_new1() as cm1, new_new_new2(): - pass -``` diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_allow_empty_first_line.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_allow_empty_first_line.py.snap deleted file mode 100644 index 2503e39477cf4..0000000000000 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_allow_empty_first_line.py.snap +++ /dev/null @@ -1,325 +0,0 @@ ---- -source: crates/ruff_python_formatter/tests/fixtures.rs -input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line.py -snapshot_kind: text ---- -## Input - -```python -def foo(): - """ - Docstring - """ - - # Here we go - if x: - - # This is also now fine - a = 123 - - else: - # But not necessary - a = 123 - - if y: - - while True: - - """ - Long comment here - """ - a = 123 - - if z: - - for _ in range(100): - a = 123 - else: - - try: - - # this should be ok - a = 123 - except: - - """also this""" - a = 123 - - -def bar(): - - if x: - a = 123 - - -def baz(): - - # OK - if x: - a = 123 - -def quux(): - - new_line = here - - -class Cls: - - def method(self): - - pass - - -async def async_fn(): - - """Docstring.""" - - -@decorated -async def async_fn(): - - """Docstring.""" - - -def top_level( - a: int, - b: str, -) -> Whatever[Generic, Something]: - - def nested(x: int) -> int: - pass -``` - -## Black Differences - -```diff ---- Black -+++ Ruff -@@ -5,7 +5,6 @@ - - # Here we go - if x: -- - # This is also now fine - a = 123 - -@@ -14,52 +13,41 @@ - a = 123 - - if y: -- - while True: -- - """ - Long comment here - """ - a = 123 - - if z: -- - for _ in range(100): - a = 123 - else: -- - try: -- - # this should be ok - a = 123 - except: -- - """also this""" - a = 123 - - - def bar(): -- - if x: - a = 123 - - - def baz(): -- - # OK - if x: - a = 123 - - - def quux(): -- - new_line = here - - - class Cls: -- - def method(self): -- - pass - - -@@ -76,6 +64,5 @@ - a: int, - b: str, - ) -> Whatever[Generic, Something]: -- - def nested(x: int) -> int: - pass -``` - -## Ruff Output - -```python -def foo(): - """ - Docstring - """ - - # Here we go - if x: - # This is also now fine - a = 123 - - else: - # But not necessary - a = 123 - - if y: - while True: - """ - Long comment here - """ - a = 123 - - if z: - for _ in range(100): - a = 123 - else: - try: - # this should be ok - a = 123 - except: - """also this""" - a = 123 - - -def bar(): - if x: - a = 123 - - -def baz(): - # OK - if x: - a = 123 - - -def quux(): - new_line = here - - -class Cls: - def method(self): - pass - - -async def async_fn(): - """Docstring.""" - - -@decorated -async def async_fn(): - """Docstring.""" - - -def top_level( - a: int, - b: str, -) -> Whatever[Generic, Something]: - def nested(x: int) -> int: - pass -``` - -## Black Output - -```python -def foo(): - """ - Docstring - """ - - # Here we go - if x: - - # This is also now fine - a = 123 - - else: - # But not necessary - a = 123 - - if y: - - while True: - - """ - Long comment here - """ - a = 123 - - if z: - - for _ in range(100): - a = 123 - else: - - try: - - # this should be ok - a = 123 - except: - - """also this""" - a = 123 - - -def bar(): - - if x: - a = 123 - - -def baz(): - - # OK - if x: - a = 123 - - -def quux(): - - new_line = here - - -class Cls: - - def method(self): - - pass - - -async def async_fn(): - """Docstring.""" - - -@decorated -async def async_fn(): - """Docstring.""" - - -def top_level( - a: int, - b: str, -) -> Whatever[Generic, Something]: - - def nested(x: int) -> int: - pass -``` diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_allow_empty_first_line_in_special_cases.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_allow_empty_first_line_in_special_cases.py.snap deleted file mode 100644 index 6ed5f158494d2..0000000000000 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_allow_empty_first_line_in_special_cases.py.snap +++ /dev/null @@ -1,217 +0,0 @@ ---- -source: crates/ruff_python_formatter/tests/fixtures.rs -input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_allow_empty_first_line_in_special_cases.py -snapshot_kind: text ---- -## Input - -```python -def foo(): - """ - Docstring - """ - - # Here we go - if x: - - # This is also now fine - a = 123 - - else: - # But not necessary - a = 123 - - if y: - - while True: - - """ - Long comment here - """ - a = 123 - - if z: - - for _ in range(100): - a = 123 - else: - - try: - - # this should be ok - a = 123 - except: - - """also this""" - a = 123 - - -def bar(): - - if x: - a = 123 - - -def baz(): - - # OK - if x: - a = 123 -``` - -## Black Differences - -```diff ---- Black -+++ Ruff -@@ -5,7 +5,6 @@ - - # Here we go - if x: -- - # This is also now fine - a = 123 - -@@ -14,38 +13,30 @@ - a = 123 - - if y: -- - while True: -- - """ - Long comment here - """ - a = 123 - - if z: -- - for _ in range(100): - a = 123 - else: -- - try: -- - # this should be ok - a = 123 - except: -- - """also this""" - a = 123 - - - def bar(): -- - if x: - a = 123 - - - def baz(): -- - # OK - if x: - a = 123 -``` - -## Ruff Output - -```python -def foo(): - """ - Docstring - """ - - # Here we go - if x: - # This is also now fine - a = 123 - - else: - # But not necessary - a = 123 - - if y: - while True: - """ - Long comment here - """ - a = 123 - - if z: - for _ in range(100): - a = 123 - else: - try: - # this should be ok - a = 123 - except: - """also this""" - a = 123 - - -def bar(): - if x: - a = 123 - - -def baz(): - # OK - if x: - a = 123 -``` - -## Black Output - -```python -def foo(): - """ - Docstring - """ - - # Here we go - if x: - - # This is also now fine - a = 123 - - else: - # But not necessary - a = 123 - - if y: - - while True: - - """ - Long comment here - """ - a = 123 - - if z: - - for _ in range(100): - a = 123 - else: - - try: - - # this should be ok - a = 123 - except: - - """also this""" - a = 123 - - -def bar(): - - if x: - a = 123 - - -def baz(): - - # OK - if x: - a = 123 -``` diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_docstring_no_string_normalization.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_docstring_no_string_normalization.py.snap deleted file mode 100644 index fe947871697bd..0000000000000 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_docstring_no_string_normalization.py.snap +++ /dev/null @@ -1,67 +0,0 @@ ---- -source: crates/ruff_python_formatter/tests/fixtures.rs -input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_docstring_no_string_normalization.py -snapshot_kind: text ---- -## Input - -```python -def do_not_touch_this_prefix(): - R"""There was a bug where docstring prefixes would be normalized even with -S.""" - - -def do_not_touch_this_prefix2(): - FR'There was a bug where docstring prefixes would be normalized even with -S.' - - -def do_not_touch_this_prefix3(): - u'''There was a bug where docstring prefixes would be normalized even with -S.''' -``` - -## Black Differences - -```diff ---- Black -+++ Ruff -@@ -3,8 +3,8 @@ - - - def do_not_touch_this_prefix2(): -- FR'There was a bug where docstring prefixes would be normalized even with -S.' -+ Rf"There was a bug where docstring prefixes would be normalized even with -S." - - - def do_not_touch_this_prefix3(): -- u'''There was a bug where docstring prefixes would be normalized even with -S.''' -+ """There was a bug where docstring prefixes would be normalized even with -S.""" -``` - -## Ruff Output - -```python -def do_not_touch_this_prefix(): - R"""There was a bug where docstring prefixes would be normalized even with -S.""" - - -def do_not_touch_this_prefix2(): - Rf"There was a bug where docstring prefixes would be normalized even with -S." - - -def do_not_touch_this_prefix3(): - """There was a bug where docstring prefixes would be normalized even with -S.""" -``` - -## Black Output - -```python -def do_not_touch_this_prefix(): - R"""There was a bug where docstring prefixes would be normalized even with -S.""" - - -def do_not_touch_this_prefix2(): - FR'There was a bug where docstring prefixes would be normalized even with -S.' - - -def do_not_touch_this_prefix3(): - u'''There was a bug where docstring prefixes would be normalized even with -S.''' -``` diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_form_feeds.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_form_feeds.py.snap deleted file mode 100644 index 3532bf00b6a42..0000000000000 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_form_feeds.py.snap +++ /dev/null @@ -1,457 +0,0 @@ ---- -source: crates/ruff_python_formatter/tests/fixtures.rs -input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_form_feeds.py -snapshot_kind: text ---- -## Input - -```python -# Warning! This file contains form feeds (ASCII 0x0C, often represented by \f or ^L). -# These may be invisible in your editor: ensure you can see them before making changes here. - -# There's one at the start that'll get stripped - -# Comment and statement processing is different enough that we'll test variations of both -# contexts here - -# - - -# - - -# - - - -# - - - -# - - - -# - - -# - - - -# - -# - -# - - \ -# -pass - -pass - - -pass - - -pass - - - -pass - - - -pass - - - -pass - - -pass - - - -pass - -pass - -pass - - -# form feed after a dedent -def foo(): - pass - -pass - - -# form feeds are prohibited inside blocks, or on a line with nonwhitespace - def bar( a = 1 ,b : bool = False ) : - - - pass - - -class Baz: - - def __init__(self): - pass - - - def something(self): - pass - - - -# -pass -pass # -a = 1 - # - pass - a = 1 - -a = [ - -] - -# as internal whitespace of a comment is allowed but why -"form feed literal in a string is okay " - -# form feeds at the very end get removed. -``` - -## Black Differences - -```diff ---- Black -+++ Ruff -@@ -5,62 +5,62 @@ - - # Comment and statement processing is different enough that we'll test variations of both - # contexts here -- -+ - # - -- -+ - # - -- -+ - # - -- -+ - # - -- -+ - # - -- -+ - # - -- -+ - # - -- -+ - # -- -+ - # -- -+ - # - - # - pass -- -+ - pass - -- -+ - pass - -- -+ - pass - -- -+ - pass - -- -+ - pass - -- -+ - pass - -- -+ - pass - -- -+ - pass -- -+ - pass -- -+ - pass - - -@@ -68,25 +68,23 @@ - def foo(): - pass - -- -+ - pass - - - # form feeds are prohibited inside blocks, or on a line with nonwhitespace - def bar(a=1, b: bool = False): -- - pass - - - class Baz: -- - def __init__(self): - pass - - def something(self): - pass - -- -+ - # - pass - pass # -``` - -## Ruff Output - -```python -# Warning! This file contains form feeds (ASCII 0x0C, often represented by \f or ^L). -# These may be invisible in your editor: ensure you can see them before making changes here. - -# There's one at the start that'll get stripped - -# Comment and statement processing is different enough that we'll test variations of both -# contexts here - -# - - -# - - -# - - -# - - -# - - -# - - -# - - -# - -# - -# - -# -pass - -pass - - -pass - - -pass - - -pass - - -pass - - -pass - - -pass - - -pass - -pass - -pass - - -# form feed after a dedent -def foo(): - pass - - -pass - - -# form feeds are prohibited inside blocks, or on a line with nonwhitespace -def bar(a=1, b: bool = False): - pass - - -class Baz: - def __init__(self): - pass - - def something(self): - pass - - -# -pass -pass # -a = 1 -# -pass -a = 1 - -a = [] - -# as internal whitespace of a comment is allowed but why -"form feed literal in a string is okay " - -# form feeds at the very end get removed. -``` - -## Black Output - -```python -# Warning! This file contains form feeds (ASCII 0x0C, often represented by \f or ^L). -# These may be invisible in your editor: ensure you can see them before making changes here. - -# There's one at the start that'll get stripped - -# Comment and statement processing is different enough that we'll test variations of both -# contexts here - -# - - -# - - -# - - -# - - -# - - -# - - -# - - -# - -# - -# - -# -pass - -pass - - -pass - - -pass - - -pass - - -pass - - -pass - - -pass - - -pass - -pass - -pass - - -# form feed after a dedent -def foo(): - pass - - -pass - - -# form feeds are prohibited inside blocks, or on a line with nonwhitespace -def bar(a=1, b: bool = False): - - pass - - -class Baz: - - def __init__(self): - pass - - def something(self): - pass - - -# -pass -pass # -a = 1 -# -pass -a = 1 - -a = [] - -# as internal whitespace of a comment is allowed but why -"form feed literal in a string is okay " - -# form feeds at the very end get removed. -``` diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_pattern_matching_trailing_comma.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_pattern_matching_trailing_comma.py.snap deleted file mode 100644 index d94102fe60fdc..0000000000000 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_pattern_matching_trailing_comma.py.snap +++ /dev/null @@ -1,103 +0,0 @@ ---- -source: crates/ruff_python_formatter/tests/fixtures.rs -input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_pattern_matching_trailing_comma.py -snapshot_kind: text ---- -## Input - -```python -match maybe, multiple: - case perhaps, 5: - pass - case perhaps, 6,: - pass - - -match more := (than, one), indeed,: - case _, (5, 6): - pass - case [[5], (6)], [7],: - pass - case _: - pass -``` - -## Black Differences - -```diff ---- Black -+++ Ruff -@@ -8,13 +8,16 @@ - pass - - --match more := (than, one), indeed,: -+match ( -+ more := (than, one), -+ indeed, -+): - case _, (5, 6): - pass -- case ( -+ case [ - [[5], (6)], - [7], -- ): -+ ]: - pass - case _: - pass -``` - -## Ruff Output - -```python -match maybe, multiple: - case perhaps, 5: - pass - case ( - perhaps, - 6, - ): - pass - - -match ( - more := (than, one), - indeed, -): - case _, (5, 6): - pass - case [ - [[5], (6)], - [7], - ]: - pass - case _: - pass -``` - -## Black Output - -```python -match maybe, multiple: - case perhaps, 5: - pass - case ( - perhaps, - 6, - ): - pass - - -match more := (than, one), indeed,: - case _, (5, 6): - pass - case ( - [[5], (6)], - [7], - ): - pass - case _: - pass -``` diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_percent_precedence.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_percent_precedence.py.snap deleted file mode 100644 index 5de6b53e3be60..0000000000000 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_percent_precedence.py.snap +++ /dev/null @@ -1,98 +0,0 @@ ---- -source: crates/ruff_python_formatter/tests/fixtures.rs -input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_percent_precedence.py -snapshot_kind: text ---- -## Input - -```python -("" % a) ** 2 -("" % a)[0] -("" % a)() -("" % a).b - -2 * ("" % a) -2 @ ("" % a) -2 / ("" % a) -2 // ("" % a) -2 % ("" % a) -+("" % a) -b + ("" % a) --("" % a) -b - ("" % a) -b + -("" % a) -~("" % a) -2 ** ("" % a) -await ("" % a) -b[("" % a)] -b(("" % a)) -``` - -## Black Differences - -```diff ---- Black -+++ Ruff -@@ -9,9 +9,9 @@ - 2 // ("" % a) - 2 % ("" % a) - +("" % a) --b + "" % a -+b + ("" % a) - -("" % a) --b - "" % a -+b - ("" % a) - b + -("" % a) - ~("" % a) - 2 ** ("" % a) -``` - -## Ruff Output - -```python -("" % a) ** 2 -("" % a)[0] -("" % a)() -("" % a).b - -2 * ("" % a) -2 @ ("" % a) -2 / ("" % a) -2 // ("" % a) -2 % ("" % a) -+("" % a) -b + ("" % a) --("" % a) -b - ("" % a) -b + -("" % a) -~("" % a) -2 ** ("" % a) -await ("" % a) -b[("" % a)] -b(("" % a)) -``` - -## Black Output - -```python -("" % a) ** 2 -("" % a)[0] -("" % a)() -("" % a).b - -2 * ("" % a) -2 @ ("" % a) -2 / ("" % a) -2 // ("" % a) -2 % ("" % a) -+("" % a) -b + "" % a --("" % a) -b - "" % a -b + -("" % a) -~("" % a) -2 ** ("" % a) -await ("" % a) -b[("" % a)] -b(("" % a)) -``` diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_prefer_rhs_split.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_prefer_rhs_split.py.snap deleted file mode 100644 index 6c4d49d07a6d1..0000000000000 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_prefer_rhs_split.py.snap +++ /dev/null @@ -1,353 +0,0 @@ ---- -source: crates/ruff_python_formatter/tests/fixtures.rs -input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_prefer_rhs_split.py -snapshot_kind: text ---- -## Input - -```python -first_item, second_item = ( - some_looooooooong_module.some_looooooooooooooong_function_name( - first_argument, second_argument, third_argument - ) -) - -some_dict["with_a_long_key"] = ( - some_looooooooong_module.some_looooooooooooooong_function_name( - first_argument, second_argument, third_argument - ) -) - -# Make sure it works when the RHS only has one pair of (optional) parens. -first_item, second_item = ( - some_looooooooong_module.SomeClass.some_looooooooooooooong_variable_name -) - -some_dict["with_a_long_key"] = ( - some_looooooooong_module.SomeClass.some_looooooooooooooong_variable_name -) - -# Make sure chaining assignments work. -first_item, second_item, third_item, forth_item = m["everything"] = ( - some_looooooooong_module.some_looooooooooooooong_function_name( - first_argument, second_argument, third_argument - ) -) - -# Make sure when the RHS's first split at the non-optional paren fits, -# we split there instead of the outer RHS optional paren. -first_item, second_item = some_looooooooong_module.some_loooooog_function_name( - first_argument, second_argument, third_argument -) - -( - first_item, - second_item, - third_item, - forth_item, - fifth_item, - last_item_very_loooooong, -) = some_looooooooong_module.some_looooooooooooooong_function_name( - first_argument, second_argument, third_argument -) - -( - first_item, - second_item, - third_item, - forth_item, - fifth_item, - last_item_very_loooooong, -) = everything = some_looooong_function_name( - first_argument, second_argument, third_argument -) - - -# Make sure unsplittable type ignore won't be moved. -some_kind_of_table[some_key] = util.some_function( # type: ignore # noqa: E501 - some_arg -).intersection(pk_cols) - -some_kind_of_table[ - some_key -] = lambda obj: obj.some_long_named_method() # type: ignore # noqa: E501 - -some_kind_of_table[ - some_key # type: ignore # noqa: E501 -] = lambda obj: obj.some_long_named_method() - - -# Make when when the left side of assignment plus the opening paren "... = (" is -# exactly line length limit + 1, it won't be split like that. -xxxxxxxxx_yyy_zzzzzzzz[ - xx.xxxxxx(x_yyy_zzzzzz.xxxxx[0]), x_yyy_zzzzzz.xxxxxx(xxxx=1) -] = 1 - - -# Right side of assignment contains un-nested pairs of inner parens. -some_kind_of_instance.some_kind_of_map[a_key] = ( - isinstance(some_var, SomeClass) - and table.something_and_something != table.something_else -) or ( - isinstance(some_other_var, BaseClass) and table.something != table.some_other_thing -) - -# Multiple targets -a = b = ( - ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc -) - -a = b = c = d = e = f = g = ( - hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh -) = i = j = ( - kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk -) - -a = ( - bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb -) = c - -a = ( - bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb -) = ( - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc -) = ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd -``` - -## Black Differences - -```diff ---- Black -+++ Ruff -@@ -60,9 +60,7 @@ - some_arg - ).intersection(pk_cols) - --some_kind_of_table[ -- some_key --] = lambda obj: obj.some_long_named_method() # type: ignore # noqa: E501 -+some_kind_of_table[some_key] = lambda obj: obj.some_long_named_method() # type: ignore # noqa: E501 - - some_kind_of_table[ - some_key # type: ignore # noqa: E501 -``` - -## Ruff Output - -```python -first_item, second_item = ( - some_looooooooong_module.some_looooooooooooooong_function_name( - first_argument, second_argument, third_argument - ) -) - -some_dict["with_a_long_key"] = ( - some_looooooooong_module.some_looooooooooooooong_function_name( - first_argument, second_argument, third_argument - ) -) - -# Make sure it works when the RHS only has one pair of (optional) parens. -first_item, second_item = ( - some_looooooooong_module.SomeClass.some_looooooooooooooong_variable_name -) - -some_dict["with_a_long_key"] = ( - some_looooooooong_module.SomeClass.some_looooooooooooooong_variable_name -) - -# Make sure chaining assignments work. -first_item, second_item, third_item, forth_item = m["everything"] = ( - some_looooooooong_module.some_looooooooooooooong_function_name( - first_argument, second_argument, third_argument - ) -) - -# Make sure when the RHS's first split at the non-optional paren fits, -# we split there instead of the outer RHS optional paren. -first_item, second_item = some_looooooooong_module.some_loooooog_function_name( - first_argument, second_argument, third_argument -) - -( - first_item, - second_item, - third_item, - forth_item, - fifth_item, - last_item_very_loooooong, -) = some_looooooooong_module.some_looooooooooooooong_function_name( - first_argument, second_argument, third_argument -) - -( - first_item, - second_item, - third_item, - forth_item, - fifth_item, - last_item_very_loooooong, -) = everything = some_looooong_function_name( - first_argument, second_argument, third_argument -) - - -# Make sure unsplittable type ignore won't be moved. -some_kind_of_table[some_key] = util.some_function( # type: ignore # noqa: E501 - some_arg -).intersection(pk_cols) - -some_kind_of_table[some_key] = lambda obj: obj.some_long_named_method() # type: ignore # noqa: E501 - -some_kind_of_table[ - some_key # type: ignore # noqa: E501 -] = lambda obj: obj.some_long_named_method() - - -# Make when when the left side of assignment plus the opening paren "... = (" is -# exactly line length limit + 1, it won't be split like that. -xxxxxxxxx_yyy_zzzzzzzz[ - xx.xxxxxx(x_yyy_zzzzzz.xxxxx[0]), x_yyy_zzzzzz.xxxxxx(xxxx=1) -] = 1 - - -# Right side of assignment contains un-nested pairs of inner parens. -some_kind_of_instance.some_kind_of_map[a_key] = ( - isinstance(some_var, SomeClass) - and table.something_and_something != table.something_else -) or ( - isinstance(some_other_var, BaseClass) and table.something != table.some_other_thing -) - -# Multiple targets -a = b = ( - ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc -) - -a = b = c = d = e = f = g = ( - hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh -) = i = j = ( - kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk -) - -a = ( - bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb -) = c - -a = ( - bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb -) = ( - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc -) = ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd -``` - -## Black Output - -```python -first_item, second_item = ( - some_looooooooong_module.some_looooooooooooooong_function_name( - first_argument, second_argument, third_argument - ) -) - -some_dict["with_a_long_key"] = ( - some_looooooooong_module.some_looooooooooooooong_function_name( - first_argument, second_argument, third_argument - ) -) - -# Make sure it works when the RHS only has one pair of (optional) parens. -first_item, second_item = ( - some_looooooooong_module.SomeClass.some_looooooooooooooong_variable_name -) - -some_dict["with_a_long_key"] = ( - some_looooooooong_module.SomeClass.some_looooooooooooooong_variable_name -) - -# Make sure chaining assignments work. -first_item, second_item, third_item, forth_item = m["everything"] = ( - some_looooooooong_module.some_looooooooooooooong_function_name( - first_argument, second_argument, third_argument - ) -) - -# Make sure when the RHS's first split at the non-optional paren fits, -# we split there instead of the outer RHS optional paren. -first_item, second_item = some_looooooooong_module.some_loooooog_function_name( - first_argument, second_argument, third_argument -) - -( - first_item, - second_item, - third_item, - forth_item, - fifth_item, - last_item_very_loooooong, -) = some_looooooooong_module.some_looooooooooooooong_function_name( - first_argument, second_argument, third_argument -) - -( - first_item, - second_item, - third_item, - forth_item, - fifth_item, - last_item_very_loooooong, -) = everything = some_looooong_function_name( - first_argument, second_argument, third_argument -) - - -# Make sure unsplittable type ignore won't be moved. -some_kind_of_table[some_key] = util.some_function( # type: ignore # noqa: E501 - some_arg -).intersection(pk_cols) - -some_kind_of_table[ - some_key -] = lambda obj: obj.some_long_named_method() # type: ignore # noqa: E501 - -some_kind_of_table[ - some_key # type: ignore # noqa: E501 -] = lambda obj: obj.some_long_named_method() - - -# Make when when the left side of assignment plus the opening paren "... = (" is -# exactly line length limit + 1, it won't be split like that. -xxxxxxxxx_yyy_zzzzzzzz[ - xx.xxxxxx(x_yyy_zzzzzz.xxxxx[0]), x_yyy_zzzzzz.xxxxxx(xxxx=1) -] = 1 - - -# Right side of assignment contains un-nested pairs of inner parens. -some_kind_of_instance.some_kind_of_map[a_key] = ( - isinstance(some_var, SomeClass) - and table.something_and_something != table.something_else -) or ( - isinstance(some_other_var, BaseClass) and table.something != table.some_other_thing -) - -# Multiple targets -a = b = ( - ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc -) - -a = b = c = d = e = f = g = ( - hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh -) = i = j = ( - kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk -) - -a = ( - bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb -) = c - -a = ( - bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb -) = ( - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc -) = ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd -``` diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_single_line_format_skip_with_multiple_comments.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_single_line_format_skip_with_multiple_comments.py.snap deleted file mode 100644 index 05b3ba4a8720e..0000000000000 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__preview_single_line_format_skip_with_multiple_comments.py.snap +++ /dev/null @@ -1,62 +0,0 @@ ---- -source: crates/ruff_python_formatter/tests/fixtures.rs -input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_single_line_format_skip_with_multiple_comments.py -snapshot_kind: text ---- -## Input - -```python -foo = 123 # fmt: skip # noqa: E501 # pylint -bar = ( - 123 , - ( 1 + 5 ) # pylint # fmt:skip -) -baz = "a" + "b" # pylint; fmt: skip; noqa: E501 -skip_will_not_work = "a" + "b" # pylint fmt:skip -skip_will_not_work2 = "a" + "b" # some text; fmt:skip happens to be part of it -``` - -## Black Differences - -```diff ---- Black -+++ Ruff -@@ -1,8 +1,8 @@ - foo = 123 # fmt: skip # noqa: E501 # pylint - bar = ( -- 123 , -- ( 1 + 5 ) # pylint # fmt:skip -+ 123, -+ (1 + 5), # pylint # fmt:skip - ) --baz = "a" + "b" # pylint; fmt: skip; noqa: E501 -+baz = "a" + "b" # pylint; fmt: skip; noqa: E501 - skip_will_not_work = "a" + "b" # pylint fmt:skip - skip_will_not_work2 = "a" + "b" # some text; fmt:skip happens to be part of it -``` - -## Ruff Output - -```python -foo = 123 # fmt: skip # noqa: E501 # pylint -bar = ( - 123, - (1 + 5), # pylint # fmt:skip -) -baz = "a" + "b" # pylint; fmt: skip; noqa: E501 -skip_will_not_work = "a" + "b" # pylint fmt:skip -skip_will_not_work2 = "a" + "b" # some text; fmt:skip happens to be part of it -``` - -## Black Output - -```python -foo = 123 # fmt: skip # noqa: E501 # pylint -bar = ( - 123 , - ( 1 + 5 ) # pylint # fmt:skip -) -baz = "a" + "b" # pylint; fmt: skip; noqa: E501 -skip_will_not_work = "a" + "b" # pylint fmt:skip -skip_will_not_work2 = "a" + "b" # some text; fmt:skip happens to be part of it -``` 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 deleted file mode 100644 index c270ff00c4485..0000000000000 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@conditional_expression.py.snap +++ /dev/null @@ -1,333 +0,0 @@ ---- -source: crates/ruff_python_formatter/tests/fixtures.rs -input_file: crates/ruff_python_formatter/resources/test/fixtures/black/conditional_expression.py -snapshot_kind: text ---- -## Input - -```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, - baz="hello, this is a another value", -) - -multiline_kwargs_indented = 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, - baz="hello, this is a another value", -) - -imploding_kwargs = my_function( - foo="test, this is a sample value", - bar=a - if foo - else b, - baz="hello, this is a another value", -) - -imploding_line = ( - 1 - if 1 + 1 == 2 - else 0 -) - -exploding_line = "hello this is a slightly long string" if some_long_value_name_foo_bar_baz else "this one is a little shorter" - -positional_argument_test(some_long_value_name_foo_bar_baz if some_boolean_variable else some_fallback_value_foo_bar_baz) - -def weird_default_argument(x=some_long_value_name_foo_bar_baz - if SOME_CONSTANT - else some_fallback_value_foo_bar_baz): - pass - -nested = "hello this is a slightly long string" if (some_long_value_name_foo_bar_baz if - nesting_test_expressions else some_fallback_value_foo_bar_baz) \ - else "this one is a little shorter" - -generator_expression = ( - some_long_value_name_foo_bar_baz if some_boolean_variable else some_fallback_value_foo_bar_baz for some_boolean_variable in some_iterable -) - - -def limit_offset_sql(self, low_mark, high_mark): - """Return LIMIT/OFFSET SQL clause.""" - limit, offset = self._get_limit_offset_params(low_mark, high_mark) - return " ".join( - sql - for sql in ( - "LIMIT %d" % limit if limit else None, - ("OFFSET %d" % offset) if offset else None, - ) - if sql - ) - - -def something(): - clone._iterable_class = ( - NamedValuesListIterable - if named - else FlatValuesListIterable - if flat - else ValuesListIterable - ) -``` - -## Black Differences - -```diff ---- Black -+++ Ruff -@@ -1,20 +1,16 @@ - 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 -- ), -+ bar=some_long_value_name_foo_bar_baz -+ if some_boolean_variable -+ else some_fallback_value_foo_bar_baz, - baz="hello, this is a another value", - ) - - multiline_kwargs_indented = 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 -- ), -+ bar=some_long_value_name_foo_bar_baz -+ if some_boolean_variable -+ else some_fallback_value_foo_bar_baz, - baz="hello, this is a another value", - ) - -@@ -40,11 +36,9 @@ - - - def weird_default_argument( -- x=( -- some_long_value_name_foo_bar_baz -- if SOME_CONSTANT -- else some_fallback_value_foo_bar_baz -- ), -+ x=some_long_value_name_foo_bar_baz -+ if SOME_CONSTANT -+ else some_fallback_value_foo_bar_baz, - ): - pass - -@@ -60,11 +54,9 @@ - ) - - generator_expression = ( -- ( -- some_long_value_name_foo_bar_baz -- if some_boolean_variable -- else some_fallback_value_foo_bar_baz -- ) -+ some_long_value_name_foo_bar_baz -+ if some_boolean_variable -+ else some_fallback_value_foo_bar_baz - for some_boolean_variable in some_iterable - ) - -@@ -86,5 +78,7 @@ - clone._iterable_class = ( - NamedValuesListIterable - if named -- else FlatValuesListIterable if flat else ValuesListIterable -+ else FlatValuesListIterable -+ if flat -+ else ValuesListIterable - ) -``` - -## Ruff Output - -```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, - baz="hello, this is a another value", -) - -multiline_kwargs_indented = 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, - baz="hello, this is a another value", -) - -imploding_kwargs = my_function( - foo="test, this is a sample value", - bar=a if foo else b, - baz="hello, this is a another value", -) - -imploding_line = 1 if 1 + 1 == 2 else 0 - -exploding_line = ( - "hello this is a slightly long string" - if some_long_value_name_foo_bar_baz - else "this one is a little shorter" -) - -positional_argument_test( - some_long_value_name_foo_bar_baz - if some_boolean_variable - else some_fallback_value_foo_bar_baz -) - - -def weird_default_argument( - x=some_long_value_name_foo_bar_baz - if SOME_CONSTANT - else some_fallback_value_foo_bar_baz, -): - pass - - -nested = ( - "hello this is a slightly long string" - if ( - some_long_value_name_foo_bar_baz - if nesting_test_expressions - else some_fallback_value_foo_bar_baz - ) - else "this one is a little shorter" -) - -generator_expression = ( - some_long_value_name_foo_bar_baz - if some_boolean_variable - else some_fallback_value_foo_bar_baz - for some_boolean_variable in some_iterable -) - - -def limit_offset_sql(self, low_mark, high_mark): - """Return LIMIT/OFFSET SQL clause.""" - limit, offset = self._get_limit_offset_params(low_mark, high_mark) - return " ".join( - sql - for sql in ( - "LIMIT %d" % limit if limit else None, - ("OFFSET %d" % offset) if offset else None, - ) - if sql - ) - - -def something(): - clone._iterable_class = ( - NamedValuesListIterable - if named - else FlatValuesListIterable - if flat - else ValuesListIterable - ) -``` - -## Black Output - -```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 - ), - baz="hello, this is a another value", -) - -multiline_kwargs_indented = 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 - ), - baz="hello, this is a another value", -) - -imploding_kwargs = my_function( - foo="test, this is a sample value", - bar=a if foo else b, - baz="hello, this is a another value", -) - -imploding_line = 1 if 1 + 1 == 2 else 0 - -exploding_line = ( - "hello this is a slightly long string" - if some_long_value_name_foo_bar_baz - else "this one is a little shorter" -) - -positional_argument_test( - some_long_value_name_foo_bar_baz - if some_boolean_variable - else some_fallback_value_foo_bar_baz -) - - -def weird_default_argument( - x=( - some_long_value_name_foo_bar_baz - if SOME_CONSTANT - else some_fallback_value_foo_bar_baz - ), -): - pass - - -nested = ( - "hello this is a slightly long string" - if ( - some_long_value_name_foo_bar_baz - if nesting_test_expressions - else some_fallback_value_foo_bar_baz - ) - else "this one is a little shorter" -) - -generator_expression = ( - ( - some_long_value_name_foo_bar_baz - if some_boolean_variable - else some_fallback_value_foo_bar_baz - ) - for some_boolean_variable in some_iterable -) - - -def limit_offset_sql(self, low_mark, high_mark): - """Return LIMIT/OFFSET SQL clause.""" - limit, offset = self._get_limit_offset_params(low_mark, high_mark) - return " ".join( - sql - for sql in ( - "LIMIT %d" % limit if limit else None, - ("OFFSET %d" % offset) if offset else None, - ) - if sql - ) - - -def something(): - clone._iterable_class = ( - NamedValuesListIterable - if named - else FlatValuesListIterable if flat else ValuesListIterable - ) -``` 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 deleted file mode 100644 index 736ef3026db14..0000000000000 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__force_pyi.py.snap +++ /dev/null @@ -1,179 +0,0 @@ ---- -source: crates/ruff_python_formatter/tests/fixtures.rs -input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellaneous/force_pyi.py -snapshot_kind: text ---- -## Input - -```python -from typing import Union - -@bird -def zoo(): ... - -class A: ... -@bar -class B: - def BMethod(self) -> None: ... - @overload - def BMethod(self, arg : List[str]) -> None: ... - -class C: ... -@hmm -class D: ... -class E: ... - -@baz -def foo() -> None: - ... - -class F (A , C): ... -def spam() -> None: ... - -@overload -def spam(arg: str) -> str: ... - -var : int = 1 - -def eggs() -> Union[str, int]: ... -``` - -## Black Differences - -```diff ---- Black -+++ Ruff -@@ -1,32 +1,45 @@ - from typing import Union - -+ - @bird - def zoo(): ... - -+ - class A: ... - -+ - @bar - class B: - def BMethod(self) -> None: ... - @overload - def BMethod(self, arg: List[str]) -> None: ... - -+ - class C: ... - -+ - @hmm - class D: ... - -+ - class E: ... - -+ - @baz - def foo() -> None: ... - -+ - class F(A, C): ... - -+ - def spam() -> None: ... -+ -+ - @overload - def spam(arg: str) -> str: ... - -+ - var: int = 1 - -+ - def eggs() -> Union[str, int]: ... -``` - -## Ruff Output - -```python -from typing import Union - - -@bird -def zoo(): ... - - -class A: ... - - -@bar -class B: - def BMethod(self) -> None: ... - @overload - def BMethod(self, arg: List[str]) -> None: ... - - -class C: ... - - -@hmm -class D: ... - - -class E: ... - - -@baz -def foo() -> None: ... - - -class F(A, C): ... - - -def spam() -> None: ... - - -@overload -def spam(arg: str) -> str: ... - - -var: int = 1 - - -def eggs() -> Union[str, int]: ... -``` - -## Black Output - -```python -from typing import Union - -@bird -def zoo(): ... - -class A: ... - -@bar -class B: - def BMethod(self) -> None: ... - @overload - def BMethod(self, arg: List[str]) -> None: ... - -class C: ... - -@hmm -class D: ... - -class E: ... - -@baz -def foo() -> None: ... - -class F(A, C): ... - -def spam() -> None: ... -@overload -def spam(arg: str) -> str: ... - -var: int = 1 - -def eggs() -> Union[str, int]: ... -``` 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 deleted file mode 100644 index 0e6b1af5db94e..0000000000000 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@raw_docstring.py.snap +++ /dev/null @@ -1,85 +0,0 @@ ---- -source: crates/ruff_python_formatter/tests/fixtures.rs -input_file: crates/ruff_python_formatter/resources/test/fixtures/black/raw_docstring.py -snapshot_kind: text ---- -## Input - -```python -# flags: --preview --skip-string-normalization -class C: - - r"""Raw""" - -def f(): - - r"""Raw""" - -class SingleQuotes: - - - r'''Raw''' - -class UpperCaseR: - R"""Raw""" -``` - -## Black Differences - -```diff ---- Black -+++ Ruff -@@ -1,3 +1,4 @@ -+# flags: --preview --skip-string-normalization - class C: - r"""Raw""" - -@@ -7,7 +8,7 @@ - - - class SingleQuotes: -- r'''Raw''' -+ r"""Raw""" - - - class UpperCaseR: -``` - -## Ruff Output - -```python -# flags: --preview --skip-string-normalization -class C: - r"""Raw""" - - -def f(): - r"""Raw""" - - -class SingleQuotes: - r"""Raw""" - - -class UpperCaseR: - R"""Raw""" -``` - -## Black Output - -```python -class C: - r"""Raw""" - - -def f(): - r"""Raw""" - - -class SingleQuotes: - r'''Raw''' - - -class UpperCaseR: - R"""Raw""" -``` diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__preview_hug_parens_with_braces_and_square_brackets.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__preview_hug_parens_with_braces_and_square_brackets.py.snap deleted file mode 100644 index dfb50126e665f..0000000000000 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__preview_hug_parens_with_braces_and_square_brackets.py.snap +++ /dev/null @@ -1,542 +0,0 @@ ---- -source: crates/ruff_python_formatter/tests/fixtures.rs -input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/preview_hug_parens_with_braces_and_square_brackets.py -snapshot_kind: text ---- -## Input - -```python -def foo_brackets(request): - return JsonResponse( - { - "var_1": foo, - "var_2": bar, - } - ) - -def foo_square_brackets(request): - return JsonResponse( - [ - "var_1", - "var_2", - ] - ) - -func({"a": 37, "b": 42, "c": 927, "aaaaaaaaaaaaaaaaaaaaaaaaa": 11111111111111111111111111111111111111111}) - -func(["random_string_number_one","random_string_number_two","random_string_number_three","random_string_number_four"]) - -func( - { - # expand me - 'a':37, - 'b':42, - 'c':927 - } -) - -func( - [ - 'a', - 'b', - 'c', - ] -) - -func( - [ - 'a', - 'b', - 'c', - ], -) - -func( # a - [ # b - "c", # c - "d", # d - "e", # e - ] # f -) # g - -func( # a - { # b - "c": 1, # c - "d": 2, # d - "e": 3, # e - } # f -) # g - -func( - # preserve me - [ - "c", - "d", - "e", - ] -) - -func( - [ # preserve me but hug brackets - "c", - "d", - "e", - ] -) - -func( - [ - # preserve me but hug brackets - "c", - "d", - "e", - ] -) - -func( - [ - "c", - # preserve me but hug brackets - "d", - "e", - ] -) - -func( - [ - "c", - "d", - "e", - # preserve me but hug brackets - ] -) - -func( - [ - "c", - "d", - "e", - ] # preserve me but hug brackets -) - -func( - [ - "c", - "d", - "e", - ] - # preserve me -) - -func([x for x in "short line"]) -func([x for x in "long line long line long line long line long line long line long line"]) -func([x for x in [x for x in "long line long line long line long line long line long line long line"]]) - -func({"short line"}) -func({"long line", "long long line", "long long long line", "long long long long line", "long long long long long line"}) -func({{"long line", "long long line", "long long long line", "long long long long line", "long long long long long line"}}) - -foooooooooooooooooooo( - [{c: n + 1 for c in range(256)} for n in range(100)] + [{}], {size} -) - -baaaaaaaaaaaaar( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], {x}, "a string", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] -) - -foo(*["long long long long long line", "long long long long long line", "long long long long long line"]) - -foo(*[str(i) for i in range(100000000000000000000000000000000000000000000000000000000000)]) -``` - -## Black Differences - -```diff ---- Black -+++ Ruff -@@ -47,17 +47,21 @@ - ], - ) - --func([ # a # b -- "c", # c -- "d", # d -- "e", # e --]) # f # g -+func( # a -+ [ # b -+ "c", # c -+ "d", # d -+ "e", # e -+ ] # f -+) # g - --func({ # a # b -- "c": 1, # c -- "d": 2, # d -- "e": 3, # e --}) # f # g -+func( # a -+ { # b -+ "c": 1, # c -+ "d": 2, # d -+ "e": 3, # e -+ } # f -+) # g - - func( - # preserve me -@@ -95,11 +99,13 @@ - # preserve me but hug brackets - ]) - --func([ -- "c", -- "d", -- "e", --]) # preserve me but hug brackets -+func( -+ [ -+ "c", -+ "d", -+ "e", -+ ] # preserve me but hug brackets -+) - - func( - [ -``` - -## Ruff Output - -```python -def foo_brackets(request): - return JsonResponse({ - "var_1": foo, - "var_2": bar, - }) - - -def foo_square_brackets(request): - return JsonResponse([ - "var_1", - "var_2", - ]) - - -func({ - "a": 37, - "b": 42, - "c": 927, - "aaaaaaaaaaaaaaaaaaaaaaaaa": 11111111111111111111111111111111111111111, -}) - -func([ - "random_string_number_one", - "random_string_number_two", - "random_string_number_three", - "random_string_number_four", -]) - -func({ - # expand me - "a": 37, - "b": 42, - "c": 927, -}) - -func([ - "a", - "b", - "c", -]) - -func( - [ - "a", - "b", - "c", - ], -) - -func( # a - [ # b - "c", # c - "d", # d - "e", # e - ] # f -) # g - -func( # a - { # b - "c": 1, # c - "d": 2, # d - "e": 3, # e - } # f -) # g - -func( - # preserve me - [ - "c", - "d", - "e", - ] -) - -func([ # preserve me but hug brackets - "c", - "d", - "e", -]) - -func([ - # preserve me but hug brackets - "c", - "d", - "e", -]) - -func([ - "c", - # preserve me but hug brackets - "d", - "e", -]) - -func([ - "c", - "d", - "e", - # preserve me but hug brackets -]) - -func( - [ - "c", - "d", - "e", - ] # preserve me but hug brackets -) - -func( - [ - "c", - "d", - "e", - ] - # preserve me -) - -func([x for x in "short line"]) -func([ - x for x in "long line long line long line long line long line long line long line" -]) -func([ - x - for x in [ - x - for x in "long line long line long line long line long line long line long line" - ] -]) - -func({"short line"}) -func({ - "long line", - "long long line", - "long long long line", - "long long long long line", - "long long long long long line", -}) -func({ - { - "long line", - "long long line", - "long long long line", - "long long long long line", - "long long long long long line", - } -}) - -foooooooooooooooooooo( - [{c: n + 1 for c in range(256)} for n in range(100)] + [{}], {size} -) - -baaaaaaaaaaaaar( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], {x}, "a string", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] -) - -foo(*[ - "long long long long long line", - "long long long long long line", - "long long long long long line", -]) - -foo(*[ - str(i) for i in range(100000000000000000000000000000000000000000000000000000000000) -]) -``` - -## Black Output - -```python -def foo_brackets(request): - return JsonResponse({ - "var_1": foo, - "var_2": bar, - }) - - -def foo_square_brackets(request): - return JsonResponse([ - "var_1", - "var_2", - ]) - - -func({ - "a": 37, - "b": 42, - "c": 927, - "aaaaaaaaaaaaaaaaaaaaaaaaa": 11111111111111111111111111111111111111111, -}) - -func([ - "random_string_number_one", - "random_string_number_two", - "random_string_number_three", - "random_string_number_four", -]) - -func({ - # expand me - "a": 37, - "b": 42, - "c": 927, -}) - -func([ - "a", - "b", - "c", -]) - -func( - [ - "a", - "b", - "c", - ], -) - -func([ # a # b - "c", # c - "d", # d - "e", # e -]) # f # g - -func({ # a # b - "c": 1, # c - "d": 2, # d - "e": 3, # e -}) # f # g - -func( - # preserve me - [ - "c", - "d", - "e", - ] -) - -func([ # preserve me but hug brackets - "c", - "d", - "e", -]) - -func([ - # preserve me but hug brackets - "c", - "d", - "e", -]) - -func([ - "c", - # preserve me but hug brackets - "d", - "e", -]) - -func([ - "c", - "d", - "e", - # preserve me but hug brackets -]) - -func([ - "c", - "d", - "e", -]) # preserve me but hug brackets - -func( - [ - "c", - "d", - "e", - ] - # preserve me -) - -func([x for x in "short line"]) -func([ - x for x in "long line long line long line long line long line long line long line" -]) -func([ - x - for x in [ - x - for x in "long line long line long line long line long line long line long line" - ] -]) - -func({"short line"}) -func({ - "long line", - "long long line", - "long long long line", - "long long long long line", - "long long long long long line", -}) -func({ - { - "long line", - "long long line", - "long long long line", - "long long long long line", - "long long long long long line", - } -}) - -foooooooooooooooooooo( - [{c: n + 1 for c in range(256)} for n in range(100)] + [{}], {size} -) - -baaaaaaaaaaaaar( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], {x}, "a string", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] -) - -foo(*[ - "long long long long long line", - "long long long long long line", - "long long long long long line", -]) - -foo(*[ - str(i) for i in range(100000000000000000000000000000000000000000000000000000000000) -]) -``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@blank_line_before_class_docstring.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@blank_line_before_class_docstring.py.snap index 897eaa535a84d..935a8ef83c5e6 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@blank_line_before_class_docstring.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@blank_line_before_class_docstring.py.snap @@ -57,7 +57,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Enabled -target_version = Py38 +target_version = Py39 source_type = Python ``` 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 b439d76070263..411f4d8eba924 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@docstring.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@docstring.py.snap @@ -176,7 +176,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -352,7 +352,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -528,7 +528,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -704,7 +704,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -880,7 +880,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@docstring_code_examples.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@docstring_code_examples.py.snap index e3880d0fb87ba..f6c50122e611e 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@docstring_code_examples.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@docstring_code_examples.py.snap @@ -1369,7 +1369,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -2741,7 +2741,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -4113,7 +4113,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -5485,7 +5485,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -6857,7 +6857,7 @@ magic-trailing-comma = Respect docstring-code = Enabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -8222,7 +8222,7 @@ magic-trailing-comma = Respect docstring-code = Enabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -9587,7 +9587,7 @@ magic-trailing-comma = Respect docstring-code = Enabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -10961,7 +10961,7 @@ magic-trailing-comma = Respect docstring-code = Enabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -12326,7 +12326,7 @@ magic-trailing-comma = Respect docstring-code = Enabled docstring-code-line-width = 60 preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -13700,7 +13700,7 @@ magic-trailing-comma = Respect docstring-code = Enabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@docstring_code_examples_crlf.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@docstring_code_examples_crlf.py.snap index 60ba598a2df0f..a0fc4e1569fdd 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@docstring_code_examples_crlf.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@docstring_code_examples_crlf.py.snap @@ -28,7 +28,7 @@ magic-trailing-comma = Respect docstring-code = Enabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@docstring_code_examples_dynamic_line_width.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@docstring_code_examples_dynamic_line_width.py.snap index 50aa25960fbf5..9e4114283a391 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@docstring_code_examples_dynamic_line_width.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@docstring_code_examples_dynamic_line_width.py.snap @@ -309,7 +309,7 @@ magic-trailing-comma = Respect docstring-code = Enabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -860,7 +860,7 @@ magic-trailing-comma = Respect docstring-code = Enabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -1386,7 +1386,7 @@ magic-trailing-comma = Respect docstring-code = Enabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -1937,7 +1937,7 @@ magic-trailing-comma = Respect docstring-code = Enabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@docstring_tab_indentation.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@docstring_tab_indentation.py.snap index 05ac1a888d9d4..944e17a4313a3 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@docstring_tab_indentation.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@docstring_tab_indentation.py.snap @@ -91,7 +91,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -185,7 +185,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` 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 b283d84cfbc94..cd075a0ee304d 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 @@ -141,7 +141,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -324,7 +324,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` 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 2d00c181189ef..407dcccf3f3d4 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 @@ -367,7 +367,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Enabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -742,7 +742,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__join_implicit_concatenated_string.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__join_implicit_concatenated_string.py.snap index 0b033ce915db9..45dabeaccc2f4 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__join_implicit_concatenated_string.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__join_implicit_concatenated_string.py.snap @@ -340,7 +340,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Enabled -target_version = Py38 +target_version = Py39 source_type = Python ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__join_implicit_concatenated_string_assignment.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__join_implicit_concatenated_string_assignment.py.snap index c160fa4dc907b..641f53d963fc4 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__join_implicit_concatenated_string_assignment.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__join_implicit_concatenated_string_assignment.py.snap @@ -312,7 +312,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Enabled -target_version = Py38 +target_version = Py39 source_type = Python ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__join_implicit_concatenated_string_preserve.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__join_implicit_concatenated_string_preserve.py.snap index aa52acf55472e..848aa3e45f3c2 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__join_implicit_concatenated_string_preserve.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__join_implicit_concatenated_string_preserve.py.snap @@ -32,7 +32,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Enabled -target_version = Py38 +target_version = Py39 source_type = Python ``` 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 8ecc488b8da7a..88286c2ae8b6b 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 @@ -216,7 +216,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -528,7 +528,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` 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 8d687c5eae8b5..b421cb853d912 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 @@ -38,7 +38,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -76,7 +76,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` 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 d7752e3cc9c9b..8f0b24ff9bc24 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 @@ -19,7 +19,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -38,7 +38,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -57,7 +57,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` 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 d6786958b8459..8599c14ac710b 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 @@ -34,7 +34,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -69,7 +69,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -104,7 +104,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@notebook_docstring.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@notebook_docstring.py.snap index 3e18863e39c33..8cce047f7d8fb 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@notebook_docstring.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@notebook_docstring.py.snap @@ -25,7 +25,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Ipynb ``` @@ -49,7 +49,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` 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 c4e1bfb4760e3..d7ccd4a5dffd6 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@preview.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@preview.py.snap @@ -85,7 +85,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -168,7 +168,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Enabled -target_version = Py38 +target_version = Py39 source_type = Python ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@quote_style.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@quote_style.py.snap index 293edf4573f93..61fbba6cbd1a8 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@quote_style.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@quote_style.py.snap @@ -69,7 +69,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -165,7 +165,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -261,7 +261,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@range_formatting__docstring_code_examples.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@range_formatting__docstring_code_examples.py.snap index a97d21118fb22..c2ed1d06745ba 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@range_formatting__docstring_code_examples.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@range_formatting__docstring_code_examples.py.snap @@ -122,7 +122,7 @@ magic-trailing-comma = Respect docstring-code = Enabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -274,7 +274,7 @@ magic-trailing-comma = Respect docstring-code = Enabled docstring-code-line-width = 88 preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@range_formatting__indent.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@range_formatting__indent.py.snap index f7cbac49574a3..83aedb02a7615 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@range_formatting__indent.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@range_formatting__indent.py.snap @@ -82,7 +82,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -161,7 +161,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -240,7 +240,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@range_formatting__stub.pyi.snap b/crates/ruff_python_formatter/tests/snapshots/format@range_formatting__stub.pyi.snap index c46a56df6024a..46a70ee0983cf 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@range_formatting__stub.pyi.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@range_formatting__stub.pyi.snap @@ -35,7 +35,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Enabled -target_version = Py38 +target_version = Py39 source_type = Stub ``` 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 0030c400eee48..0d18ca41c976a 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 @@ -52,7 +52,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -110,7 +110,7 @@ magic-trailing-comma = Ignore docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__assignment_split_value_first.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__assignment_split_value_first.py.snap index 53b78380e81a5..746b781681493 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__assignment_split_value_first.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__assignment_split_value_first.py.snap @@ -254,7 +254,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Enabled -target_version = Py38 +target_version = Py39 source_type = Python ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@stub_files__blank_line_after_nested_stub_class.pyi.snap b/crates/ruff_python_formatter/tests/snapshots/format@stub_files__blank_line_after_nested_stub_class.pyi.snap index 05d856ccf8c31..cbd5976f311ae 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@stub_files__blank_line_after_nested_stub_class.pyi.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@stub_files__blank_line_after_nested_stub_class.pyi.snap @@ -202,7 +202,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Enabled -target_version = Py38 +target_version = Py39 source_type = Stub ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@stub_files__blank_line_after_nested_stub_class_eof.pyi.snap b/crates/ruff_python_formatter/tests/snapshots/format@stub_files__blank_line_after_nested_stub_class_eof.pyi.snap index d8c03ade9eb24..aecb66882c488 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@stub_files__blank_line_after_nested_stub_class_eof.pyi.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@stub_files__blank_line_after_nested_stub_class_eof.pyi.snap @@ -36,7 +36,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Enabled -target_version = Py38 +target_version = Py39 source_type = Stub ``` 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 6e7bbc62a08ec..76744a4c58587 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 @@ -27,7 +27,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -54,7 +54,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` @@ -84,7 +84,7 @@ magic-trailing-comma = Respect docstring-code = Disabled docstring-code-line-width = "dynamic" preview = Disabled -target_version = Py38 +target_version = Py39 source_type = Python ``` diff --git a/crates/ruff_workspace/src/options.rs b/crates/ruff_workspace/src/options.rs index 7d9cdbfced931..1d045e6ca850d 100644 --- a/crates/ruff_workspace/src/options.rs +++ b/crates/ruff_workspace/src/options.rs @@ -322,8 +322,8 @@ pub struct Options { /// file than it would for an equivalent runtime file with the same target /// version. #[option( - default = r#""py38""#, - value_type = r#""py37" | "py38" | "py39" | "py310" | "py311" | "py312""#, + default = r#""py39""#, + value_type = r#""py37" | "py38" | "py39" | "py310" | "py311" | "py312" | "py313""#, example = r#" # Always generate Python 3.7-compatible code. target-version = "py37" @@ -3408,7 +3408,9 @@ pub struct AnalyzeOptions { mod tests { use crate::options::Flake8SelfOptions; use ruff_linter::rules::flake8_self; + use ruff_linter::settings::types::PythonVersion as LinterPythonVersion; use ruff_python_ast::name::Name; + use ruff_python_formatter::PythonVersion as FormatterPythonVersion; #[test] fn flake8_self_options() { @@ -3456,4 +3458,28 @@ mod tests { vec![Name::new_static("_foo"), Name::new_static("_bar")] ); } + + #[test] + fn formatter_and_linter_target_version_have_same_default() { + assert_eq!( + FormatterPythonVersion::default().as_tuple(), + LinterPythonVersion::default().as_tuple() + ); + } + + #[test] + fn formatter_and_linter_target_version_have_same_latest() { + assert_eq!( + FormatterPythonVersion::latest().as_tuple(), + LinterPythonVersion::latest().as_tuple() + ); + } + + #[test] + fn formatter_and_linter_target_version_have_same_minimal_supported() { + assert_eq!( + FormatterPythonVersion::minimal_supported().as_tuple(), + LinterPythonVersion::minimal_supported().as_tuple() + ); + } } diff --git a/docs/configuration.md b/docs/configuration.md index 20da0743dfa64..916942d642dcb 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -47,8 +47,8 @@ If left unspecified, Ruff's default configuration is equivalent to: line-length = 88 indent-width = 4 - # Assume Python 3.8 - target-version = "py38" + # Assume Python 3.9 + target-version = "py39" [tool.ruff.lint] # Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. @@ -129,8 +129,8 @@ If left unspecified, Ruff's default configuration is equivalent to: line-length = 88 indent-width = 4 - # Assume Python 3.8 - target-version = "py38" + # Assume Python 3.9 + target-version = "py39" [lint] # Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.