From d54883e201ce40936b17054882cc0eb2c4656c00 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Fri, 20 Dec 2024 12:55:16 -0500 Subject: [PATCH 01/18] crates: vendor `annotate-snippets` crate This merely adds the crate to our repository. Some cosmetic changes are made to make it work in our repo and follow our conventions, such as changing the name to `ruff_annotate_snippets`. We retain the original license information. We do drop some things, such as benchmarks, but keep tests and examples. --- Cargo.lock | 196 +- Cargo.toml | 5 + crates/ruff_annotate_snippets/Cargo.toml | 37 + crates/ruff_annotate_snippets/LICENSE-APACHE | 202 ++ crates/ruff_annotate_snippets/LICENSE-MIT | 19 + crates/ruff_annotate_snippets/README.md | 15 + .../examples/expected_type.rs | 23 + .../examples/expected_type.svg | 46 + .../ruff_annotate_snippets/examples/footer.rs | 22 + .../examples/footer.svg | 43 + .../ruff_annotate_snippets/examples/format.rs | 44 + .../examples/format.svg | 83 + .../examples/multislice.rs | 19 + .../examples/multislice.svg | 44 + crates/ruff_annotate_snippets/src/lib.rs | 67 + .../src/renderer/display_list.rs | 1736 +++++++++++++++++ .../src/renderer/margin.rs | 119 ++ .../src/renderer/mod.rs | 163 ++ .../src/renderer/styled_buffer.rs | 97 + .../src/renderer/stylesheet.rs | 68 + crates/ruff_annotate_snippets/src/snippet.rs | 157 ++ .../ruff_annotate_snippets/tests/examples.rs | 37 + .../tests/fixtures/color/ann_eof.svg | 36 + .../tests/fixtures/color/ann_eof.toml | 15 + .../tests/fixtures/color/ann_insertion.svg | 36 + .../tests/fixtures/color/ann_insertion.toml | 15 + .../tests/fixtures/color/ann_multiline.svg | 42 + .../tests/fixtures/color/ann_multiline.toml | 21 + .../tests/fixtures/color/ann_multiline2.svg | 40 + .../tests/fixtures/color/ann_multiline2.toml | 21 + .../tests/fixtures/color/ann_removed_nl.svg | 36 + .../tests/fixtures/color/ann_removed_nl.toml | 15 + .../color/ensure-emoji-highlight-width.svg | 36 + .../color/ensure-emoji-highlight-width.toml | 18 + .../fixtures/color/fold_ann_multiline.svg | 49 + .../fixtures/color/fold_ann_multiline.toml | 44 + .../fixtures/color/fold_bad_origin_line.svg | 37 + .../fixtures/color/fold_bad_origin_line.toml | 20 + .../tests/fixtures/color/fold_leading.svg | 36 + .../tests/fixtures/color/fold_leading.toml | 29 + .../tests/fixtures/color/fold_trailing.svg | 36 + .../tests/fixtures/color/fold_trailing.toml | 28 + .../tests/fixtures/color/issue_9.svg | 49 + .../tests/fixtures/color/issue_9.toml | 31 + .../fixtures/color/multiple_annotations.svg | 54 + .../fixtures/color/multiple_annotations.toml | 32 + .../tests/fixtures/color/simple.svg | 43 + .../tests/fixtures/color/simple.toml | 22 + .../tests/fixtures/color/strip_line.svg | 36 + .../tests/fixtures/color/strip_line.toml | 18 + .../tests/fixtures/color/strip_line_char.svg | 36 + .../tests/fixtures/color/strip_line_char.toml | 18 + .../fixtures/color/strip_line_non_ws.svg | 40 + .../fixtures/color/strip_line_non_ws.toml | 26 + .../tests/fixtures/deserialize.rs | 130 ++ .../tests/fixtures/main.rs | 42 + .../ruff_annotate_snippets/tests/formatter.rs | 963 +++++++++ .../tests/rustc_tests.rs | 783 ++++++++ 58 files changed, 6168 insertions(+), 7 deletions(-) create mode 100644 crates/ruff_annotate_snippets/Cargo.toml create mode 100644 crates/ruff_annotate_snippets/LICENSE-APACHE create mode 100644 crates/ruff_annotate_snippets/LICENSE-MIT create mode 100644 crates/ruff_annotate_snippets/README.md create mode 100644 crates/ruff_annotate_snippets/examples/expected_type.rs create mode 100644 crates/ruff_annotate_snippets/examples/expected_type.svg create mode 100644 crates/ruff_annotate_snippets/examples/footer.rs create mode 100644 crates/ruff_annotate_snippets/examples/footer.svg create mode 100644 crates/ruff_annotate_snippets/examples/format.rs create mode 100644 crates/ruff_annotate_snippets/examples/format.svg create mode 100644 crates/ruff_annotate_snippets/examples/multislice.rs create mode 100644 crates/ruff_annotate_snippets/examples/multislice.svg create mode 100644 crates/ruff_annotate_snippets/src/lib.rs create mode 100644 crates/ruff_annotate_snippets/src/renderer/display_list.rs create mode 100644 crates/ruff_annotate_snippets/src/renderer/margin.rs create mode 100644 crates/ruff_annotate_snippets/src/renderer/mod.rs create mode 100644 crates/ruff_annotate_snippets/src/renderer/styled_buffer.rs create mode 100644 crates/ruff_annotate_snippets/src/renderer/stylesheet.rs create mode 100644 crates/ruff_annotate_snippets/src/snippet.rs create mode 100644 crates/ruff_annotate_snippets/tests/examples.rs create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/ann_eof.svg create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/ann_eof.toml create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/ann_insertion.svg create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/ann_insertion.toml create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/ann_multiline.svg create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/ann_multiline.toml create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/ann_multiline2.svg create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/ann_multiline2.toml create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/ann_removed_nl.svg create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/ann_removed_nl.toml create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/ensure-emoji-highlight-width.svg create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/ensure-emoji-highlight-width.toml create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/fold_ann_multiline.svg create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/fold_ann_multiline.toml create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/fold_bad_origin_line.svg create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/fold_bad_origin_line.toml create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/fold_leading.svg create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/fold_leading.toml create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/fold_trailing.svg create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/fold_trailing.toml create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/issue_9.svg create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/issue_9.toml create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/multiple_annotations.svg create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/multiple_annotations.toml create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/simple.svg create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/simple.toml create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/strip_line.svg create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/strip_line.toml create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/strip_line_char.svg create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/strip_line_char.toml create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/strip_line_non_ws.svg create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/color/strip_line_non_ws.toml create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/deserialize.rs create mode 100644 crates/ruff_annotate_snippets/tests/fixtures/main.rs create mode 100644 crates/ruff_annotate_snippets/tests/formatter.rs create mode 100644 crates/ruff_annotate_snippets/tests/rustc_tests.rs diff --git a/Cargo.lock b/Cargo.lock index 710480ff89117..2a28d178fa101 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -69,23 +69,33 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.13" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.8" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" + +[[package]] +name = "anstyle-lossy" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" +checksum = "934ff8719effd2023a48cf63e69536c1c3ced9d3895068f6f5cc9a4ff845e59b" +dependencies = [ + "anstyle", +] [[package]] name = "anstyle-parse" @@ -105,14 +115,27 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "anstyle-svg" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3607949e9f6de49ea4bafe12f5e4fd73613ebf24795e48587302a8cc0e4bb35" +dependencies = [ + "anstream", + "anstyle", + "anstyle-lossy", + "html-escape", + "unicode-width 0.2.0", +] + [[package]] name = "anstyle-wincon" -version = "3.0.2" +version = "3.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" dependencies = [ "anstyle", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -884,6 +907,24 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "escape8259" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5692dd7b5a1978a5aeb0ce83b7655c58ca8efdcb79d21036ea249da95afec2c6" + +[[package]] +name = "escargot" +version = "0.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05a3ac187a16b5382fef8c69fd1bad123c67b7cf3932240a2d43dcdd32cded88" +dependencies = [ + "log", + "once_cell", + "serde", + "serde_json", +] + [[package]] name = "etcetera" version = "0.8.0" @@ -1082,6 +1123,15 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "html-escape" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d1ad449764d627e22bfd7cd5e8868264fc9236e07c752972b4080cd351cb476" +dependencies = [ + "utf8-width", +] + [[package]] name = "humantime" version = "2.1.0" @@ -1424,6 +1474,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itertools" version = "0.10.5" @@ -1560,6 +1616,18 @@ dependencies = [ "redox_syscall 0.5.3", ] +[[package]] +name = "libtest-mimic" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc0bda45ed5b3a2904262c1bb91e526127aa70e7ef3758aba2ef93cf896b9b58" +dependencies = [ + "clap", + "escape8259", + "termcolor", + "threadpool", +] + [[package]] name = "linked-hash-map" version = "0.5.6" @@ -1730,6 +1798,12 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "normalize-line-endings" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" + [[package]] name = "notify" version = "7.0.0" @@ -1786,6 +1860,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + [[package]] name = "number_prefix" version = "0.4.0" @@ -1819,6 +1903,16 @@ dependencies = [ "indexmap", ] +[[package]] +name = "os_pipe" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ffd2b0a5634335b135d5728d84c5e0fd726954b87111f7506a61c502280d982" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + [[package]] name = "os_str_bytes" version = "7.0.0" @@ -2552,6 +2646,21 @@ dependencies = [ "wild", ] +[[package]] +name = "ruff_annotate_snippets" +version = "0.1.0" +dependencies = [ + "anstream", + "anstyle", + "memchr", + "ruff_annotate_snippets", + "serde", + "snapbox", + "toml", + "tryfn", + "unicode-width 0.2.0", +] + [[package]] name = "ruff_benchmark" version = "0.0.0" @@ -3419,6 +3528,35 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +[[package]] +name = "snapbox" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96dcfc4581e3355d70ac2ee14cfdf81dce3d85c85f1ed9e2c1d3013f53b3436b" +dependencies = [ + "anstream", + "anstyle", + "anstyle-svg", + "escargot", + "libc", + "normalize-line-endings", + "os_pipe", + "serde_json", + "similar", + "snapbox-macros", + "wait-timeout", + "windows-sys 0.59.0", +] + +[[package]] +name = "snapbox-macros" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16569f53ca23a41bb6f62e0a5084aa1661f4814a67fa33696a79073e03a664af" +dependencies = [ + "anstream", +] + [[package]] name = "spin" version = "0.9.8" @@ -3532,6 +3670,15 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + [[package]] name = "terminal_size" version = "0.4.0" @@ -3643,6 +3790,15 @@ dependencies = [ "once_cell", ] +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + [[package]] name = "tikv-jemalloc-sys" version = "0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7" @@ -3829,6 +3985,17 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "tryfn" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fe242ee9e646acec9ab73a5c540e8543ed1b107f0ce42be831e0775d423c396" +dependencies = [ + "ignore", + "libtest-mimic", + "snapbox", +] + [[package]] name = "typed-arena" version = "2.0.2" @@ -3990,6 +4157,12 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" +[[package]] +name = "utf8-width" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3" + [[package]] name = "utf8_iter" version = "1.0.4" @@ -4079,6 +4252,15 @@ dependencies = [ "quote", ] +[[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] + [[package]] name = "walkdir" version = "2.5.0" diff --git a/Cargo.toml b/Cargo.toml index 60c66c7b6e818..121baf422cbe3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ license = "MIT" [workspace.dependencies] ruff = { path = "crates/ruff" } +ruff_annotate_snippets = { path = "crates/ruff_annotate_snippets" } ruff_cache = { path = "crates/ruff_cache" } ruff_db = { path = "crates/ruff_db", default-features = false } ruff_diagnostics = { path = "crates/ruff_diagnostics" } @@ -44,6 +45,8 @@ red_knot_workspace = { path = "crates/red_knot_workspace", default-features = fa aho-corasick = { version = "1.1.3" } annotate-snippets = { version = "0.9.2", features = ["color"] } +anstream = { version = "0.6.18" } +anstyle = { version = "1.0.10" } anyhow = { version = "1.0.80" } assert_fs = { version = "1.1.0" } argfile = { version = "0.2.0" } @@ -132,6 +135,7 @@ serde_with = { version = "3.6.0", default-features = false, features = [ shellexpand = { version = "3.0.0" } similar = { version = "2.4.0", features = ["inline"] } smallvec = { version = "1.13.2" } +snapbox = { version = "0.6.0", features = ["diff", "term-svg", "cmd", "examples"] } static_assertions = "1.1.0" strum = { version = "0.26.0", features = ["strum_macros"] } strum_macros = { version = "0.26.0" } @@ -149,6 +153,7 @@ tracing-subscriber = { version = "0.3.18", default-features = false, features = "fmt", ] } tracing-tree = { version = "0.4.0" } +tryfn = { version = "0.2.1" } typed-arena = { version = "2.0.2" } unic-ucd-category = { version = "0.9" } unicode-ident = { version = "1.0.12" } diff --git a/crates/ruff_annotate_snippets/Cargo.toml b/crates/ruff_annotate_snippets/Cargo.toml new file mode 100644 index 0000000000000..7352430948518 --- /dev/null +++ b/crates/ruff_annotate_snippets/Cargo.toml @@ -0,0 +1,37 @@ +[package] +name = "ruff_annotate_snippets" +version = "0.1.0" +publish = false +authors = { workspace = true } +edition = { workspace = true } +rust-version = { workspace = true } +homepage = { workspace = true } +documentation = { workspace = true } +repository = { workspace = true } +license = "MIT OR Apache-2.0" + +[lib] + +[features] +default = [] +testing-colors = [] + +[dependencies] +anstyle = { workspace = true } +memchr = { workspace = true } +unicode-width = { workspace = true } + +[dev-dependencies] +ruff_annotate_snippets = { workspace = true, features = ["testing-colors"] } +anstream = { workspace = true } +serde = { workspace = true, features = ["derive"] } +snapbox = { workspace = true, features = ["diff", "term-svg", "cmd", "examples"] } +toml = { workspace = true } +tryfn = { workspace = true } + +[[test]] +name = "fixtures" +harness = false + +[lints] +workspace = true diff --git a/crates/ruff_annotate_snippets/LICENSE-APACHE b/crates/ruff_annotate_snippets/LICENSE-APACHE new file mode 100644 index 0000000000000..8f71f43fee3f7 --- /dev/null +++ b/crates/ruff_annotate_snippets/LICENSE-APACHE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/crates/ruff_annotate_snippets/LICENSE-MIT b/crates/ruff_annotate_snippets/LICENSE-MIT new file mode 100644 index 0000000000000..a2d01088b6ce5 --- /dev/null +++ b/crates/ruff_annotate_snippets/LICENSE-MIT @@ -0,0 +1,19 @@ +Copyright (c) Individual contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/crates/ruff_annotate_snippets/README.md b/crates/ruff_annotate_snippets/README.md new file mode 100644 index 0000000000000..f4fc4a0de6928 --- /dev/null +++ b/crates/ruff_annotate_snippets/README.md @@ -0,0 +1,15 @@ +This is a fork of the [`annotate-snippets` crate]. The principle motivation for +this fork, at the time of writing, is [issue #167]. Specifically, we wanted to +upgrade our version of `annotate-snippets`, but do so _without_ changing our +diagnostic message format. + +This copy of `annotate-snippets` is basically identical to upstream, but with +an extra `Level::None` variant that permits skipping over a new non-optional +header emitted by `annotate-snippets`. + +More generally, it seems plausible that we may want to tweak other aspects of +the output format in the future, so it might make sense to stick with our own +copy so that we can be masters of our own destiny. + +[issue #167]: https://github.com/rust-lang/annotate-snippets-rs/issues/167 +[`annotate-snippets` crate]: https://github.com/rust-lang/annotate-snippets-rs diff --git a/crates/ruff_annotate_snippets/examples/expected_type.rs b/crates/ruff_annotate_snippets/examples/expected_type.rs new file mode 100644 index 0000000000000..80b92c90db435 --- /dev/null +++ b/crates/ruff_annotate_snippets/examples/expected_type.rs @@ -0,0 +1,23 @@ +use ruff_annotate_snippets::{Level, Renderer, Snippet}; + +fn main() { + let source = r#" annotations: vec![SourceAnnotation { + label: "expected struct `annotate_snippets::snippet::Slice`, found reference" + , + range: <22, 25>,"#; + let message = Level::Error.title("expected type, found `22`").snippet( + Snippet::source(source) + .line_start(26) + .origin("examples/footer.rs") + .fold(true) + .annotation( + Level::Error + .span(193..195) + .label("expected struct `annotate_snippets::snippet::Slice`, found reference"), + ) + .annotation(Level::Info.span(34..50).label("while parsing this struct")), + ); + + let renderer = Renderer::styled(); + anstream::println!("{}", renderer.render(message)); +} diff --git a/crates/ruff_annotate_snippets/examples/expected_type.svg b/crates/ruff_annotate_snippets/examples/expected_type.svg new file mode 100644 index 0000000000000..ed19ef385d3d8 --- /dev/null +++ b/crates/ruff_annotate_snippets/examples/expected_type.svg @@ -0,0 +1,46 @@ + + + + + + + error: expected type, found `22` + + --> examples/footer.rs:29:25 + + | + + 26 | annotations: vec![SourceAnnotation { + + | ---------------- info: while parsing this struct + + 27 | label: "expected struct `annotate_snippets::snippet::Slice`, found reference" + + 28 | , + + 29 | range: <22, 25>, + + | ^^ expected struct `annotate_snippets::snippet::Slice`, found reference + + | + + + + + + diff --git a/crates/ruff_annotate_snippets/examples/footer.rs b/crates/ruff_annotate_snippets/examples/footer.rs new file mode 100644 index 0000000000000..f2d05a15f8d05 --- /dev/null +++ b/crates/ruff_annotate_snippets/examples/footer.rs @@ -0,0 +1,22 @@ +use ruff_annotate_snippets::{Level, Renderer, Snippet}; + +fn main() { + let message = + Level::Error + .title("mismatched types") + .id("E0308") + .snippet( + Snippet::source(" slices: vec![\"A\",") + .line_start(13) + .origin("src/multislice.rs") + .annotation(Level::Error.span(21..24).label( + "expected struct `annotate_snippets::snippet::Slice`, found reference", + )), + ) + .footer(Level::Note.title( + "expected type: `snippet::Annotation`\n found type: `__&__snippet::Annotation`", + )); + + let renderer = Renderer::styled(); + anstream::println!("{}", renderer.render(message)); +} diff --git a/crates/ruff_annotate_snippets/examples/footer.svg b/crates/ruff_annotate_snippets/examples/footer.svg new file mode 100644 index 0000000000000..76e7d776bf263 --- /dev/null +++ b/crates/ruff_annotate_snippets/examples/footer.svg @@ -0,0 +1,43 @@ + + + + + + + error[E0308]: mismatched types + + --> src/multislice.rs:13:22 + + | + + 13 | slices: vec!["A", + + | ^^^ expected struct `annotate_snippets::snippet::Slice`, found reference + + | + + = note: expected type: `snippet::Annotation` + + found type: `__&__snippet::Annotation` + + + + + + diff --git a/crates/ruff_annotate_snippets/examples/format.rs b/crates/ruff_annotate_snippets/examples/format.rs new file mode 100644 index 0000000000000..2365b76f0e9f6 --- /dev/null +++ b/crates/ruff_annotate_snippets/examples/format.rs @@ -0,0 +1,44 @@ +use ruff_annotate_snippets::{Level, Renderer, Snippet}; + +fn main() { + let source = r#") -> Option { + for ann in annotations { + match (ann.range.0, ann.range.1) { + (None, None) => continue, + (Some(start), Some(end)) if start > end_index => continue, + (Some(start), Some(end)) if start >= start_index => { + let label = if let Some(ref label) = ann.label { + format!(" {}", label) + } else { + String::from("") + }; + + return Some(format!( + "{}{}{}", + " ".repeat(start - start_index), + "^".repeat(end - start), + label + )); + } + _ => continue, + } + }"#; + let message = Level::Error.title("mismatched types").id("E0308").snippet( + Snippet::source(source) + .line_start(51) + .origin("src/format.rs") + .annotation( + Level::Warning + .span(5..19) + .label("expected `Option` because of return type"), + ) + .annotation( + Level::Error + .span(26..724) + .label("expected enum `std::option::Option`"), + ), + ); + + let renderer = Renderer::styled(); + anstream::println!("{}", renderer.render(message)); +} diff --git a/crates/ruff_annotate_snippets/examples/format.svg b/crates/ruff_annotate_snippets/examples/format.svg new file mode 100644 index 0000000000000..ac196c0168556 --- /dev/null +++ b/crates/ruff_annotate_snippets/examples/format.svg @@ -0,0 +1,83 @@ + + + + + + + error[E0308]: mismatched types + + --> src/format.rs:51:6 + + | + + 51 | ) -> Option<String> { + + | -------------- expected `Option<String>` because of return type + + 52 | / for ann in annotations { + + 53 | | match (ann.range.0, ann.range.1) { + + 54 | | (None, None) => continue, + + 55 | | (Some(start), Some(end)) if start > end_index => continue, + + 56 | | (Some(start), Some(end)) if start >= start_index => { + + 57 | | let label = if let Some(ref label) = ann.label { + + 58 | | format!(" {}", label) + + 59 | | } else { + + 60 | | String::from("") + + 61 | | }; + + 62 | | + + 63 | | return Some(format!( + + 64 | | "{}{}{}", + + 65 | | " ".repeat(start - start_index), + + 66 | | "^".repeat(end - start), + + 67 | | label + + 68 | | )); + + 69 | | } + + 70 | | _ => continue, + + 71 | | } + + 72 | | } + + | |____^ expected enum `std::option::Option` + + | + + + + + + diff --git a/crates/ruff_annotate_snippets/examples/multislice.rs b/crates/ruff_annotate_snippets/examples/multislice.rs new file mode 100644 index 0000000000000..2d4e59c0e956f --- /dev/null +++ b/crates/ruff_annotate_snippets/examples/multislice.rs @@ -0,0 +1,19 @@ +use ruff_annotate_snippets::{Level, Renderer, Snippet}; + +fn main() { + let message = Level::Error + .title("mismatched types") + .snippet( + Snippet::source("Foo") + .line_start(51) + .origin("src/format.rs"), + ) + .snippet( + Snippet::source("Faa") + .line_start(129) + .origin("src/display.rs"), + ); + + let renderer = Renderer::styled(); + anstream::println!("{}", renderer.render(message)); +} diff --git a/crates/ruff_annotate_snippets/examples/multislice.svg b/crates/ruff_annotate_snippets/examples/multislice.svg new file mode 100644 index 0000000000000..216a359224444 --- /dev/null +++ b/crates/ruff_annotate_snippets/examples/multislice.svg @@ -0,0 +1,44 @@ + + + + + + + error: mismatched types + + --> src/format.rs + + | + + 51 | Foo + + | + + ::: src/display.rs + + | + + 129 | Faa + + | + + + + + + diff --git a/crates/ruff_annotate_snippets/src/lib.rs b/crates/ruff_annotate_snippets/src/lib.rs new file mode 100644 index 0000000000000..2a23dda82dee7 --- /dev/null +++ b/crates/ruff_annotate_snippets/src/lib.rs @@ -0,0 +1,67 @@ +//! A library for formatting of text or programming code snippets. +//! +//! It's primary purpose is to build an ASCII-graphical representation of the snippet +//! with annotations. +//! +//! # Example +//! +//! ```rust +#![doc = include_str!("../examples/expected_type.rs")] +//! ``` +//! +#![doc = include_str!("../examples/expected_type.svg")] +//! +//! The crate uses a three stage process with two conversions between states: +//! +//! ```text +//! Message --> Renderer --> impl Display +//! ``` +//! +//! The input type - [Message] is a structure designed +//! to align with likely output from any parser whose code snippet is to be +//! annotated. +//! +//! The middle structure - [Renderer] is a structure designed +//! to convert a snippet into an internal structure that is designed to store +//! the snippet data in a way that is easy to format. +//! [Renderer] also handles the user-configurable formatting +//! options, such as color, or margins. +//! +//! Finally, `impl Display` into a final `String` output. +//! +//! # features +//! - `testing-colors` - Makes [Renderer::styled] colors OS independent, which +//! allows for easier testing when testing colored output. It should be added as +//! a feature in `[dev-dependencies]`, which can be done with the following command: +//! ```text +//! cargo add annotate-snippets --dev --feature testing-colors +//! ``` + +#![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] +#![warn(missing_debug_implementations)] +// Since this is a vendored copy of `annotate-snippets`, we squash Clippy +// warnings from upstream in order to the reduce the diff. If our copy drifts +// far from upstream such that patches become impractical to apply in both +// places, then we can get rid of these suppressions and fix the lints. +#![allow( + clippy::return_self_not_must_use, + clippy::cast_possible_truncation, + clippy::cast_precision_loss, + clippy::explicit_iter_loop, + clippy::unused_self, + clippy::unnecessary_wraps, + clippy::range_plus_one, + clippy::redundant_closure_for_method_calls, + clippy::struct_field_names, + clippy::cloned_instead_of_copied, + clippy::cast_sign_loss +)] + +pub mod renderer; +mod snippet; + +#[doc(inline)] +pub use renderer::Renderer; +pub use snippet::*; diff --git a/crates/ruff_annotate_snippets/src/renderer/display_list.rs b/crates/ruff_annotate_snippets/src/renderer/display_list.rs new file mode 100644 index 0000000000000..b2e27d4afec34 --- /dev/null +++ b/crates/ruff_annotate_snippets/src/renderer/display_list.rs @@ -0,0 +1,1736 @@ +//! `display_list` module stores the output model for the snippet. +//! +//! `DisplayList` is a central structure in the crate, which contains +//! the structured list of lines to be displayed. +//! +//! It is made of two types of lines: `Source` and `Raw`. All `Source` lines +//! are structured using four columns: +//! +//! ```text +//! /------------ (1) Line number column. +//! | /--------- (2) Line number column delimiter. +//! | | /------- (3) Inline marks column. +//! | | | /--- (4) Content column with the source and annotations for slices. +//! | | | | +//! ============================================================================= +//! error[E0308]: mismatched types +//! --> src/format.rs:51:5 +//! | +//! 151 | / fn test() -> String { +//! 152 | | return "test"; +//! 153 | | } +//! | |___^ error: expected `String`, for `&str`. +//! | +//! ``` +//! +//! The first two lines of the example above are `Raw` lines, while the rest +//! are `Source` lines. +//! +//! `DisplayList` does not store column alignment information, and those are +//! only calculated by the implementation of `std::fmt::Display` using information such as +//! styling. +//! +//! The above snippet has been built out of the following structure: +use crate::snippet; +use std::cmp::{max, min, Reverse}; +use std::collections::HashMap; +use std::fmt::Display; +use std::ops::Range; +use std::{cmp, fmt}; + +use crate::renderer::styled_buffer::StyledBuffer; +use crate::renderer::{stylesheet::Stylesheet, Margin, Style, DEFAULT_TERM_WIDTH}; + +const ANONYMIZED_LINE_NUM: &str = "LL"; +const ERROR_TXT: &str = "error"; +const HELP_TXT: &str = "help"; +const INFO_TXT: &str = "info"; +const NOTE_TXT: &str = "note"; +const WARNING_TXT: &str = "warning"; + +/// List of lines to be displayed. +pub(crate) struct DisplayList<'a> { + pub(crate) body: Vec>, + pub(crate) stylesheet: &'a Stylesheet, + pub(crate) anonymized_line_numbers: bool, +} + +impl PartialEq for DisplayList<'_> { + fn eq(&self, other: &Self) -> bool { + self.body == other.body && self.anonymized_line_numbers == other.anonymized_line_numbers + } +} + +impl fmt::Debug for DisplayList<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("DisplayList") + .field("body", &self.body) + .field("anonymized_line_numbers", &self.anonymized_line_numbers) + .finish() + } +} + +impl Display for DisplayList<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let lineno_width = self.body.iter().fold(0, |max, set| { + set.display_lines.iter().fold(max, |max, line| match line { + DisplayLine::Source { lineno, .. } => cmp::max(lineno.unwrap_or(0), max), + _ => max, + }) + }); + let lineno_width = if lineno_width == 0 { + lineno_width + } else if self.anonymized_line_numbers { + ANONYMIZED_LINE_NUM.len() + } else { + ((lineno_width as f64).log10().floor() as usize) + 1 + }; + + let multiline_depth = self.body.iter().fold(0, |max, set| { + set.display_lines.iter().fold(max, |max2, line| match line { + DisplayLine::Source { annotations, .. } => cmp::max( + annotations.iter().fold(max2, |max3, line| { + cmp::max( + match line.annotation_part { + DisplayAnnotationPart::Standalone => 0, + DisplayAnnotationPart::LabelContinuation => 0, + DisplayAnnotationPart::MultilineStart(depth) => depth + 1, + DisplayAnnotationPart::MultilineEnd(depth) => depth + 1, + }, + max3, + ) + }), + max, + ), + _ => max2, + }) + }); + let mut buffer = StyledBuffer::new(); + for set in self.body.iter() { + self.format_set(set, lineno_width, multiline_depth, &mut buffer)?; + } + write!(f, "{}", buffer.render(self.stylesheet)?) + } +} + +impl<'a> DisplayList<'a> { + pub(crate) fn new( + message: snippet::Message<'a>, + stylesheet: &'a Stylesheet, + anonymized_line_numbers: bool, + term_width: usize, + ) -> DisplayList<'a> { + let body = format_message(message, term_width, anonymized_line_numbers, true); + + Self { + body, + stylesheet, + anonymized_line_numbers, + } + } + + fn format_set( + &self, + set: &DisplaySet<'_>, + lineno_width: usize, + multiline_depth: usize, + buffer: &mut StyledBuffer, + ) -> fmt::Result { + for line in &set.display_lines { + set.format_line( + line, + lineno_width, + multiline_depth, + self.stylesheet, + self.anonymized_line_numbers, + buffer, + )?; + } + Ok(()) + } +} + +#[derive(Debug, PartialEq)] +pub(crate) struct DisplaySet<'a> { + pub(crate) display_lines: Vec>, + pub(crate) margin: Margin, +} + +impl DisplaySet<'_> { + fn format_label( + &self, + line_offset: usize, + label: &[DisplayTextFragment<'_>], + stylesheet: &Stylesheet, + buffer: &mut StyledBuffer, + ) -> fmt::Result { + for fragment in label { + let style = match fragment.style { + DisplayTextStyle::Regular => stylesheet.none(), + DisplayTextStyle::Emphasis => stylesheet.emphasis(), + }; + buffer.append(line_offset, fragment.content, *style); + } + Ok(()) + } + fn format_annotation( + &self, + line_offset: usize, + annotation: &Annotation<'_>, + continuation: bool, + stylesheet: &Stylesheet, + buffer: &mut StyledBuffer, + ) -> fmt::Result { + let color = get_annotation_style(&annotation.annotation_type, stylesheet); + let formatted_len = if let Some(id) = &annotation.id { + 2 + id.len() + annotation_type_len(&annotation.annotation_type) + } else { + annotation_type_len(&annotation.annotation_type) + }; + + if continuation { + for _ in 0..formatted_len + 2 { + buffer.append(line_offset, " ", Style::new()); + } + return self.format_label(line_offset, &annotation.label, stylesheet, buffer); + } + if formatted_len == 0 { + self.format_label(line_offset, &annotation.label, stylesheet, buffer) + } else { + let id = match &annotation.id { + Some(id) => format!("[{id}]"), + None => String::new(), + }; + buffer.append( + line_offset, + &format!("{}{}", annotation_type_str(&annotation.annotation_type), id), + *color, + ); + + if !is_annotation_empty(annotation) { + buffer.append(line_offset, ": ", stylesheet.none); + self.format_label(line_offset, &annotation.label, stylesheet, buffer)?; + } + Ok(()) + } + } + + #[inline] + fn format_raw_line( + &self, + line_offset: usize, + line: &DisplayRawLine<'_>, + lineno_width: usize, + stylesheet: &Stylesheet, + buffer: &mut StyledBuffer, + ) -> fmt::Result { + match line { + DisplayRawLine::Origin { + path, + pos, + header_type, + } => { + let header_sigil = match header_type { + DisplayHeaderType::Initial => "-->", + DisplayHeaderType::Continuation => ":::", + }; + let lineno_color = stylesheet.line_no(); + buffer.puts(line_offset, lineno_width, header_sigil, *lineno_color); + buffer.puts(line_offset, lineno_width + 4, path, stylesheet.none); + if let Some((col, row)) = pos { + buffer.append(line_offset, ":", stylesheet.none); + buffer.append(line_offset, col.to_string().as_str(), stylesheet.none); + buffer.append(line_offset, ":", stylesheet.none); + buffer.append(line_offset, row.to_string().as_str(), stylesheet.none); + } + Ok(()) + } + DisplayRawLine::Annotation { + annotation, + source_aligned, + continuation, + } => { + if *source_aligned { + if *continuation { + for _ in 0..lineno_width + 3 { + buffer.append(line_offset, " ", stylesheet.none); + } + } else { + let lineno_color = stylesheet.line_no(); + for _ in 0..lineno_width + 1 { + buffer.append(line_offset, " ", stylesheet.none); + } + buffer.append(line_offset, "=", *lineno_color); + buffer.append(line_offset, " ", *lineno_color); + } + } + self.format_annotation(line_offset, annotation, *continuation, stylesheet, buffer) + } + } + } + + // Adapted from https://github.com/rust-lang/rust/blob/d371d17496f2ce3a56da76aa083f4ef157572c20/compiler/rustc_errors/src/emitter.rs#L706-L1211 + #[inline] + fn format_line( + &self, + dl: &DisplayLine<'_>, + lineno_width: usize, + multiline_depth: usize, + stylesheet: &Stylesheet, + anonymized_line_numbers: bool, + buffer: &mut StyledBuffer, + ) -> fmt::Result { + let line_offset = buffer.num_lines(); + match dl { + DisplayLine::Source { + lineno, + inline_marks, + line, + annotations, + } => { + let lineno_color = stylesheet.line_no(); + if anonymized_line_numbers && lineno.is_some() { + let num = format!("{ANONYMIZED_LINE_NUM:>lineno_width$} |"); + buffer.puts(line_offset, 0, &num, *lineno_color); + } else { + match lineno { + Some(n) => { + let num = format!("{n:>lineno_width$} |"); + buffer.puts(line_offset, 0, &num, *lineno_color); + } + None => { + buffer.putc(line_offset, lineno_width + 1, '|', *lineno_color); + } + }; + } + if let DisplaySourceLine::Content { text, .. } = line { + // The width of the line number, a space, pipe, and a space + // `123 | ` is `lineno_width + 3`. + let width_offset = lineno_width + 3; + let code_offset = if multiline_depth == 0 { + width_offset + } else { + width_offset + multiline_depth + 1 + }; + + // Add any inline marks to the code line + if !inline_marks.is_empty() || 0 < multiline_depth { + format_inline_marks( + line_offset, + inline_marks, + lineno_width, + stylesheet, + buffer, + )?; + } + + let text = normalize_whitespace(text); + let line_len = text.as_bytes().len(); + let left = self.margin.left(line_len); + let right = self.margin.right(line_len); + + // On long lines, we strip the source line, accounting for unicode. + let mut taken = 0; + let code: String = text + .chars() + .skip(left) + .take_while(|ch| { + // Make sure that the trimming on the right will fall within the terminal width. + // FIXME: `unicode_width` sometimes disagrees with terminals on how wide a `char` + // is. For now, just accept that sometimes the code line will be longer than + // desired. + let next = unicode_width::UnicodeWidthChar::width(*ch).unwrap_or(1); + if taken + next > right - left { + return false; + } + taken += next; + true + }) + .collect(); + buffer.puts(line_offset, code_offset, &code, Style::new()); + if self.margin.was_cut_left() { + // We have stripped some code/whitespace from the beginning, make it clear. + buffer.puts(line_offset, code_offset, "...", *lineno_color); + } + if self.margin.was_cut_right(line_len) { + buffer.puts(line_offset, code_offset + taken - 3, "...", *lineno_color); + } + + let left: usize = text + .chars() + .take(left) + .map(|ch| unicode_width::UnicodeWidthChar::width(ch).unwrap_or(1)) + .sum(); + + let mut annotations = annotations.clone(); + annotations.sort_by_key(|a| Reverse(a.range.0)); + + let mut annotations_positions = vec![]; + let mut line_len: usize = 0; + let mut p = 0; + for (i, annotation) in annotations.iter().enumerate() { + for (j, next) in annotations.iter().enumerate() { + // This label overlaps with another one and both take space ( + // they have text and are not multiline lines). + if overlaps(next, annotation, 0) + && annotation.has_label() + && j > i + && p == 0 + // We're currently on the first line, move the label one line down + { + // If we're overlapping with an un-labelled annotation with the same span + // we can just merge them in the output + if next.range.0 == annotation.range.0 + && next.range.1 == annotation.range.1 + && !next.has_label() + { + continue; + } + + // This annotation needs a new line in the output. + p += 1; + break; + } + } + annotations_positions.push((p, annotation)); + for (j, next) in annotations.iter().enumerate() { + if j > i { + let l = next + .annotation + .label + .iter() + .map(|label| label.content) + .collect::>() + .join("") + .len() + + 2; + // Do not allow two labels to be in the same line if they + // overlap including padding, to avoid situations like: + // + // fn foo(x: u32) { + // -------^------ + // | | + // fn_spanx_span + // + // Both labels must have some text, otherwise they are not + // overlapping. Do not add a new line if this annotation or + // the next are vertical line placeholders. If either this + // or the next annotation is multiline start/end, move it + // to a new line so as not to overlap the horizontal lines. + if (overlaps(next, annotation, l) + && annotation.has_label() + && next.has_label()) + || (annotation.takes_space() && next.has_label()) + || (annotation.has_label() && next.takes_space()) + || (annotation.takes_space() && next.takes_space()) + || (overlaps(next, annotation, l) + && next.range.1 <= annotation.range.1 + && next.has_label() + && p == 0) + // Avoid #42595. + { + // This annotation needs a new line in the output. + p += 1; + break; + } + } + } + line_len = max(line_len, p); + } + + if line_len != 0 { + line_len += 1; + } + + if annotations_positions.iter().all(|(_, ann)| { + matches!( + ann.annotation_part, + DisplayAnnotationPart::MultilineStart(_) + ) + }) { + if let Some(max_pos) = + annotations_positions.iter().map(|(pos, _)| *pos).max() + { + // Special case the following, so that we minimize overlapping multiline spans. + // + // 3 │ X0 Y0 Z0 + // │ ┏━━━━━┛ │ │ < We are writing these lines + // │ ┃┌───────┘ │ < by reverting the "depth" of + // │ ┃│┌─────────┘ < their multilne spans. + // 4 │ ┃││ X1 Y1 Z1 + // 5 │ ┃││ X2 Y2 Z2 + // │ ┃│└────╿──│──┘ `Z` label + // │ ┃└─────│──┤ + // │ ┗━━━━━━┥ `Y` is a good letter too + // ╰╴ `X` is a good letter + for (pos, _) in &mut annotations_positions { + *pos = max_pos - *pos; + } + // We know then that we don't need an additional line for the span label, saving us + // one line of vertical space. + line_len = line_len.saturating_sub(1); + } + } + + // This is a special case where we have a multiline + // annotation that is at the start of the line disregarding + // any leading whitespace, and no other multiline + // annotations overlap it. In this case, we want to draw + // + // 2 | fn foo() { + // | _^ + // 3 | | + // 4 | | } + // | |_^ test + // + // we simplify the output to: + // + // 2 | / fn foo() { + // 3 | | + // 4 | | } + // | |_^ test + if multiline_depth == 1 + && annotations_positions.len() == 1 + && annotations_positions + .first() + .map_or(false, |(_, annotation)| { + matches!( + annotation.annotation_part, + DisplayAnnotationPart::MultilineStart(_) + ) && text + .chars() + .take(annotation.range.0) + .all(|c| c.is_whitespace()) + }) + { + let (_, ann) = annotations_positions.remove(0); + let style = get_annotation_style(&ann.annotation_type, stylesheet); + buffer.putc(line_offset, 3 + lineno_width, '/', *style); + } + + // Draw the column separator for any extra lines that were + // created + // + // After this we will have: + // + // 2 | fn foo() { + // | + // | + // | + // 3 | + // 4 | } + // | + if !annotations_positions.is_empty() { + for pos in 0..=line_len { + buffer.putc( + line_offset + pos + 1, + lineno_width + 1, + '|', + stylesheet.line_no, + ); + } + } + + // Write the horizontal lines for multiline annotations + // (only the first and last lines need this). + // + // After this we will have: + // + // 2 | fn foo() { + // | __________ + // | + // | + // 3 | + // 4 | } + // | _ + for &(pos, annotation) in &annotations_positions { + let style = get_annotation_style(&annotation.annotation_type, stylesheet); + let pos = pos + 1; + match annotation.annotation_part { + DisplayAnnotationPart::MultilineStart(depth) + | DisplayAnnotationPart::MultilineEnd(depth) => { + for col in width_offset + depth + ..(code_offset + annotation.range.0).saturating_sub(left) + { + buffer.putc(line_offset + pos, col + 1, '_', *style); + } + } + _ => {} + } + } + + // Write the vertical lines for labels that are on a different line as the underline. + // + // After this we will have: + // + // 2 | fn foo() { + // | __________ + // | | | + // | | + // 3 | | + // 4 | | } + // | |_ + for &(pos, annotation) in &annotations_positions { + let style = get_annotation_style(&annotation.annotation_type, stylesheet); + let pos = pos + 1; + if pos > 1 && (annotation.has_label() || annotation.takes_space()) { + for p in line_offset + 2..=line_offset + pos { + buffer.putc( + p, + (code_offset + annotation.range.0).saturating_sub(left), + '|', + *style, + ); + } + } + match annotation.annotation_part { + DisplayAnnotationPart::MultilineStart(depth) => { + for p in line_offset + pos + 1..line_offset + line_len + 2 { + buffer.putc(p, width_offset + depth, '|', *style); + } + } + DisplayAnnotationPart::MultilineEnd(depth) => { + for p in line_offset..=line_offset + pos { + buffer.putc(p, width_offset + depth, '|', *style); + } + } + _ => {} + } + } + + // Add in any inline marks for any extra lines that have + // been created. Output should look like above. + for inline_mark in inline_marks { + let DisplayMarkType::AnnotationThrough(depth) = inline_mark.mark_type; + let style = get_annotation_style(&inline_mark.annotation_type, stylesheet); + if annotations_positions.is_empty() { + buffer.putc(line_offset, width_offset + depth, '|', *style); + } else { + for p in line_offset..=line_offset + line_len + 1 { + buffer.putc(p, width_offset + depth, '|', *style); + } + } + } + + // Write the labels on the annotations that actually have a label. + // + // After this we will have: + // + // 2 | fn foo() { + // | __________ + // | | + // | something about `foo` + // 3 | + // 4 | } + // | _ test + for &(pos, annotation) in &annotations_positions { + if !is_annotation_empty(&annotation.annotation) { + let style = + get_annotation_style(&annotation.annotation_type, stylesheet); + let mut formatted_len = if let Some(id) = &annotation.annotation.id { + 2 + id.len() + + annotation_type_len(&annotation.annotation.annotation_type) + } else { + annotation_type_len(&annotation.annotation.annotation_type) + }; + let (pos, col) = if pos == 0 { + (pos + 1, (annotation.range.1 + 1).saturating_sub(left)) + } else { + (pos + 2, annotation.range.0.saturating_sub(left)) + }; + if annotation.annotation_part + == DisplayAnnotationPart::LabelContinuation + { + formatted_len = 0; + } else if formatted_len != 0 { + formatted_len += 2; + let id = match &annotation.annotation.id { + Some(id) => format!("[{id}]"), + None => String::new(), + }; + buffer.puts( + line_offset + pos, + col + code_offset, + &format!( + "{}{}: ", + annotation_type_str(&annotation.annotation_type), + id + ), + *style, + ); + } else { + formatted_len = 0; + } + let mut before = 0; + for fragment in &annotation.annotation.label { + let inner_col = before + formatted_len + col + code_offset; + buffer.puts(line_offset + pos, inner_col, fragment.content, *style); + before += fragment.content.len(); + } + } + } + + // Sort from biggest span to smallest span so that smaller spans are + // represented in the output: + // + // x | fn foo() + // | ^^^---^^ + // | | | + // | | something about `foo` + // | something about `fn foo()` + annotations_positions.sort_by_key(|(_, ann)| { + // Decreasing order. When annotations share the same length, prefer `Primary`. + Reverse(ann.len()) + }); + + // Write the underlines. + // + // After this we will have: + // + // 2 | fn foo() { + // | ____-_____^ + // | | + // | something about `foo` + // 3 | + // 4 | } + // | _^ test + for &(_, annotation) in &annotations_positions { + let mark = match annotation.annotation_type { + DisplayAnnotationType::Error => '^', + DisplayAnnotationType::Warning => '-', + DisplayAnnotationType::Info => '-', + DisplayAnnotationType::Note => '-', + DisplayAnnotationType::Help => '-', + DisplayAnnotationType::None => ' ', + }; + let style = get_annotation_style(&annotation.annotation_type, stylesheet); + for p in annotation.range.0..annotation.range.1 { + buffer.putc( + line_offset + 1, + (code_offset + p).saturating_sub(left), + mark, + *style, + ); + } + } + } else if !inline_marks.is_empty() { + format_inline_marks( + line_offset, + inline_marks, + lineno_width, + stylesheet, + buffer, + )?; + } + Ok(()) + } + DisplayLine::Fold { inline_marks } => { + buffer.puts(line_offset, 0, "...", *stylesheet.line_no()); + if !inline_marks.is_empty() || 0 < multiline_depth { + format_inline_marks( + line_offset, + inline_marks, + lineno_width, + stylesheet, + buffer, + )?; + } + Ok(()) + } + DisplayLine::Raw(line) => { + self.format_raw_line(line_offset, line, lineno_width, stylesheet, buffer) + } + } + } +} + +/// Inline annotation which can be used in either Raw or Source line. +#[derive(Clone, Debug, PartialEq)] +pub(crate) struct Annotation<'a> { + pub(crate) annotation_type: DisplayAnnotationType, + pub(crate) id: Option<&'a str>, + pub(crate) label: Vec>, +} + +/// A single line used in `DisplayList`. +#[derive(Debug, PartialEq)] +pub(crate) enum DisplayLine<'a> { + /// A line with `lineno` portion of the slice. + Source { + lineno: Option, + inline_marks: Vec, + line: DisplaySourceLine<'a>, + annotations: Vec>, + }, + + /// A line indicating a folded part of the slice. + Fold { inline_marks: Vec }, + + /// A line which is displayed outside of slices. + Raw(DisplayRawLine<'a>), +} + +/// A source line. +#[derive(Debug, PartialEq)] +pub(crate) enum DisplaySourceLine<'a> { + /// A line with the content of the Snippet. + Content { + text: &'a str, + range: (usize, usize), // meta information for annotation placement. + end_line: EndLine, + }, + /// An empty source line. + Empty, +} + +#[derive(Clone, Debug, PartialEq)] +pub(crate) struct DisplaySourceAnnotation<'a> { + pub(crate) annotation: Annotation<'a>, + pub(crate) range: (usize, usize), + pub(crate) annotation_type: DisplayAnnotationType, + pub(crate) annotation_part: DisplayAnnotationPart, +} + +impl DisplaySourceAnnotation<'_> { + fn has_label(&self) -> bool { + !self + .annotation + .label + .iter() + .all(|label| label.content.is_empty()) + } + + // Length of this annotation as displayed in the stderr output + fn len(&self) -> usize { + // Account for usize underflows + if self.range.1 > self.range.0 { + self.range.1 - self.range.0 + } else { + self.range.0 - self.range.1 + } + } + + fn takes_space(&self) -> bool { + // Multiline annotations always have to keep vertical space. + matches!( + self.annotation_part, + DisplayAnnotationPart::MultilineStart(_) | DisplayAnnotationPart::MultilineEnd(_) + ) + } +} + +/// Raw line - a line which does not have the `lineno` part and is not considered +/// a part of the snippet. +#[derive(Debug, PartialEq)] +pub(crate) enum DisplayRawLine<'a> { + /// A line which provides information about the location of the given + /// slice in the project structure. + Origin { + path: &'a str, + pos: Option<(usize, usize)>, + header_type: DisplayHeaderType, + }, + + /// An annotation line which is not part of any snippet. + Annotation { + annotation: Annotation<'a>, + + /// If set to `true`, the annotation will be aligned to the + /// lineno delimiter of the snippet. + source_aligned: bool, + /// If set to `true`, only the label of the `Annotation` will be + /// displayed. It allows for a multiline annotation to be aligned + /// without displaying the meta information (`type` and `id`) to be + /// displayed on each line. + continuation: bool, + }, +} + +/// An inline text fragment which any label is composed of. +#[derive(Clone, Debug, PartialEq)] +pub(crate) struct DisplayTextFragment<'a> { + pub(crate) content: &'a str, + pub(crate) style: DisplayTextStyle, +} + +/// A style for the `DisplayTextFragment` which can be visually formatted. +/// +/// This information may be used to emphasis parts of the label. +#[derive(Debug, Clone, Copy, PartialEq)] +pub(crate) enum DisplayTextStyle { + Regular, + Emphasis, +} + +/// An indicator of what part of the annotation a given `Annotation` is. +#[derive(Debug, Clone, PartialEq)] +pub(crate) enum DisplayAnnotationPart { + /// A standalone, single-line annotation. + Standalone, + /// A continuation of a multi-line label of an annotation. + LabelContinuation, + /// A line starting a multiline annotation. + MultilineStart(usize), + /// A line ending a multiline annotation. + MultilineEnd(usize), +} + +/// A visual mark used in `inline_marks` field of the `DisplaySourceLine`. +#[derive(Debug, Clone, PartialEq)] +pub(crate) struct DisplayMark { + pub(crate) mark_type: DisplayMarkType, + pub(crate) annotation_type: DisplayAnnotationType, +} + +/// A type of the `DisplayMark`. +#[derive(Debug, Clone, PartialEq)] +pub(crate) enum DisplayMarkType { + /// A mark indicating a multiline annotation going through the current line. + AnnotationThrough(usize), +} + +/// A type of the `Annotation` which may impact the sigils, style or text displayed. +/// +/// There are several ways to uses this information when formatting the `DisplayList`: +/// +/// * An annotation may display the name of the type like `error` or `info`. +/// * An underline for `Error` may be `^^^` while for `Warning` it could be `---`. +/// * `ColorStylesheet` may use different colors for different annotations. +#[derive(Debug, Clone, PartialEq)] +pub(crate) enum DisplayAnnotationType { + None, + Error, + Warning, + Info, + Note, + Help, +} + +impl From for DisplayAnnotationType { + fn from(at: snippet::Level) -> Self { + match at { + snippet::Level::Error => DisplayAnnotationType::Error, + snippet::Level::Warning => DisplayAnnotationType::Warning, + snippet::Level::Info => DisplayAnnotationType::Info, + snippet::Level::Note => DisplayAnnotationType::Note, + snippet::Level::Help => DisplayAnnotationType::Help, + } + } +} + +/// Information whether the header is the initial one or a consequitive one +/// for multi-slice cases. +// TODO: private +#[derive(Debug, Clone, PartialEq)] +pub(crate) enum DisplayHeaderType { + /// Initial header is the first header in the snippet. + Initial, + + /// Continuation marks all headers of following slices in the snippet. + Continuation, +} + +struct CursorLines<'a>(&'a str); + +impl CursorLines<'_> { + fn new(src: &str) -> CursorLines<'_> { + CursorLines(src) + } +} + +#[derive(Copy, Clone, Debug, PartialEq)] +pub(crate) enum EndLine { + Eof, + Lf, + Crlf, +} + +impl EndLine { + /// The number of characters this line ending occupies in bytes. + pub(crate) fn len(self) -> usize { + match self { + EndLine::Eof => 0, + EndLine::Lf => 1, + EndLine::Crlf => 2, + } + } +} + +impl<'a> Iterator for CursorLines<'a> { + type Item = (&'a str, EndLine); + + fn next(&mut self) -> Option { + if self.0.is_empty() { + None + } else { + self.0 + .find('\n') + .map(|x| { + let ret = if 0 < x { + if self.0.as_bytes()[x - 1] == b'\r' { + (&self.0[..x - 1], EndLine::Crlf) + } else { + (&self.0[..x], EndLine::Lf) + } + } else { + ("", EndLine::Lf) + }; + self.0 = &self.0[x + 1..]; + ret + }) + .or_else(|| { + let ret = Some((self.0, EndLine::Eof)); + self.0 = ""; + ret + }) + } + } +} + +fn format_message( + message: snippet::Message<'_>, + term_width: usize, + anonymized_line_numbers: bool, + primary: bool, +) -> Vec> { + let snippet::Message { + level, + id, + title, + footer, + snippets, + } = message; + + let mut sets = vec![]; + let body = if !snippets.is_empty() || primary { + vec![format_title(level, id, title)] + } else { + format_footer(level, id, title) + }; + + for (idx, snippet) in snippets.into_iter().enumerate() { + let snippet = fold_prefix_suffix(snippet); + sets.push(format_snippet( + snippet, + idx == 0, + !footer.is_empty(), + term_width, + anonymized_line_numbers, + )); + } + + if let Some(first) = sets.first_mut() { + for line in body { + first.display_lines.insert(0, line); + } + } else { + sets.push(DisplaySet { + display_lines: body, + margin: Margin::new(0, 0, 0, 0, DEFAULT_TERM_WIDTH, 0), + }); + } + + for annotation in footer { + sets.extend(format_message( + annotation, + term_width, + anonymized_line_numbers, + false, + )); + } + + sets +} + +fn format_title<'a>(level: crate::Level, id: Option<&'a str>, label: &'a str) -> DisplayLine<'a> { + DisplayLine::Raw(DisplayRawLine::Annotation { + annotation: Annotation { + annotation_type: DisplayAnnotationType::from(level), + id, + label: format_label(Some(label), Some(DisplayTextStyle::Emphasis)), + }, + source_aligned: false, + continuation: false, + }) +} + +fn format_footer<'a>( + level: crate::Level, + id: Option<&'a str>, + label: &'a str, +) -> Vec> { + let mut result = vec![]; + for (i, line) in label.lines().enumerate() { + result.push(DisplayLine::Raw(DisplayRawLine::Annotation { + annotation: Annotation { + annotation_type: DisplayAnnotationType::from(level), + id, + label: format_label(Some(line), None), + }, + source_aligned: true, + continuation: i != 0, + })); + } + result +} + +fn format_label( + label: Option<&str>, + style: Option, +) -> Vec> { + let mut result = vec![]; + if let Some(label) = label { + let element_style = style.unwrap_or(DisplayTextStyle::Regular); + result.push(DisplayTextFragment { + content: label, + style: element_style, + }); + } + result +} + +fn format_snippet( + snippet: snippet::Snippet<'_>, + is_first: bool, + has_footer: bool, + term_width: usize, + anonymized_line_numbers: bool, +) -> DisplaySet<'_> { + let main_range = snippet.annotations.first().map(|x| x.range.start); + let origin = snippet.origin; + let need_empty_header = origin.is_some() || is_first; + let mut body = format_body( + snippet, + need_empty_header, + has_footer, + term_width, + anonymized_line_numbers, + ); + let header = format_header(origin, main_range, &body.display_lines, is_first); + + if let Some(header) = header { + body.display_lines.insert(0, header); + } + + body +} + +#[inline] +// TODO: option_zip +fn zip_opt(a: Option, b: Option) -> Option<(A, B)> { + a.and_then(|a| b.map(|b| (a, b))) +} + +fn format_header<'a>( + origin: Option<&'a str>, + main_range: Option, + body: &[DisplayLine<'_>], + is_first: bool, +) -> Option> { + let display_header = if is_first { + DisplayHeaderType::Initial + } else { + DisplayHeaderType::Continuation + }; + + if let Some((main_range, path)) = zip_opt(main_range, origin) { + let mut col = 1; + let mut line_offset = 1; + + for item in body { + if let DisplayLine::Source { + line: + DisplaySourceLine::Content { + text, + range, + end_line, + }, + lineno, + .. + } = item + { + if main_range >= range.0 && main_range < range.1 + max(*end_line as usize, 1) { + let char_column = text[0..(main_range - range.0).min(text.len())] + .chars() + .count(); + col = char_column + 1; + line_offset = lineno.unwrap_or(1); + break; + } + } + } + + return Some(DisplayLine::Raw(DisplayRawLine::Origin { + path, + pos: Some((line_offset, col)), + header_type: display_header, + })); + } + + if let Some(path) = origin { + return Some(DisplayLine::Raw(DisplayRawLine::Origin { + path, + pos: None, + header_type: display_header, + })); + } + + None +} + +fn fold_prefix_suffix(mut snippet: snippet::Snippet<'_>) -> snippet::Snippet<'_> { + if !snippet.fold { + return snippet; + } + + let ann_start = snippet + .annotations + .iter() + .map(|ann| ann.range.start) + .min() + .unwrap_or(0); + if let Some(before_new_start) = snippet.source[0..ann_start].rfind('\n') { + let new_start = before_new_start + 1; + + let line_offset = newline_count(&snippet.source[..new_start]); + snippet.line_start += line_offset; + + snippet.source = &snippet.source[new_start..]; + + for ann in &mut snippet.annotations { + let range_start = ann.range.start - new_start; + let range_end = ann.range.end - new_start; + ann.range = range_start..range_end; + } + } + + let ann_end = snippet + .annotations + .iter() + .map(|ann| ann.range.end) + .max() + .unwrap_or(snippet.source.len()); + if let Some(end_offset) = snippet.source[ann_end..].find('\n') { + let new_end = ann_end + end_offset; + snippet.source = &snippet.source[..new_end]; + } + + snippet +} + +fn newline_count(body: &str) -> usize { + memchr::memchr_iter(b'\n', body.as_bytes()).count() +} + +fn fold_body(body: Vec>) -> Vec> { + const INNER_CONTEXT: usize = 1; + const INNER_UNFOLD_SIZE: usize = INNER_CONTEXT * 2 + 1; + + let mut lines = vec![]; + let mut unhighlighed_lines = vec![]; + for line in body { + match &line { + DisplayLine::Source { annotations, .. } => { + if annotations.is_empty() { + unhighlighed_lines.push(line); + } else { + if lines.is_empty() { + // Ignore leading unhighlighed lines + unhighlighed_lines.clear(); + } + match unhighlighed_lines.len() { + 0 => {} + n if n <= INNER_UNFOLD_SIZE => { + // Rather than render `...`, don't fold + lines.append(&mut unhighlighed_lines); + } + _ => { + lines.extend(unhighlighed_lines.drain(..INNER_CONTEXT)); + let inline_marks = lines + .last() + .and_then(|line| { + if let DisplayLine::Source { + ref inline_marks, .. + } = line + { + let inline_marks = inline_marks.clone(); + Some(inline_marks) + } else { + None + } + }) + .unwrap_or_default(); + lines.push(DisplayLine::Fold { + inline_marks: inline_marks.clone(), + }); + unhighlighed_lines + .drain(..unhighlighed_lines.len().saturating_sub(INNER_CONTEXT)); + lines.append(&mut unhighlighed_lines); + } + } + lines.push(line); + } + } + _ => { + unhighlighed_lines.push(line); + } + } + } + + lines +} + +fn format_body( + snippet: snippet::Snippet<'_>, + need_empty_header: bool, + has_footer: bool, + term_width: usize, + anonymized_line_numbers: bool, +) -> DisplaySet<'_> { + let source_len = snippet.source.len(); + if let Some(bigger) = snippet.annotations.iter().find_map(|x| { + // Allow highlighting one past the last character in the source. + if source_len + 1 < x.range.end { + Some(&x.range) + } else { + None + } + }) { + panic!("SourceAnnotation range `{bigger:?}` is beyond the end of buffer `{source_len}`") + } + + let mut body = vec![]; + let mut current_line = snippet.line_start; + let mut current_index = 0; + + let mut whitespace_margin = usize::MAX; + let mut span_left_margin = usize::MAX; + let mut span_right_margin = 0; + let mut label_right_margin = 0; + let mut max_line_len = 0; + + let mut depth_map: HashMap = HashMap::new(); + let mut current_depth = 0; + let mut annotations = snippet.annotations; + let ranges = annotations + .iter() + .map(|a| a.range.clone()) + .collect::>(); + // We want to merge multiline annotations that have the same range into one + // multiline annotation to save space. This is done by making any duplicate + // multiline annotations into a single-line annotation pointing at the end + // of the range. + // + // 3 | X0 Y0 Z0 + // | _____^ + // | | ____| + // | || ___| + // | ||| + // 4 | ||| X1 Y1 Z1 + // 5 | ||| X2 Y2 Z2 + // | ||| ^ + // | |||____| + // | ||____`X` is a good letter + // | |____`Y` is a good letter too + // | `Z` label + // Should be + // error: foo + // --> test.rs:3:3 + // | + // 3 | / X0 Y0 Z0 + // 4 | | X1 Y1 Z1 + // 5 | | X2 Y2 Z2 + // | | ^ + // | |____| + // | `X` is a good letter + // | `Y` is a good letter too + // | `Z` label + // | + ranges.iter().enumerate().for_each(|(r_idx, range)| { + annotations + .iter_mut() + .enumerate() + .skip(r_idx + 1) + .for_each(|(ann_idx, ann)| { + // Skip if the annotation's index matches the range index + if ann_idx != r_idx + // We only want to merge multiline annotations + && snippet.source[ann.range.clone()].lines().count() > 1 + // We only want to merge annotations that have the same range + && ann.range.start == range.start + && ann.range.end == range.end + { + ann.range.start = ann.range.end.saturating_sub(1); + } + }); + }); + annotations.sort_by_key(|a| a.range.start); + let mut annotations = annotations.into_iter().enumerate().collect::>(); + + for (idx, (line, end_line)) in CursorLines::new(snippet.source).enumerate() { + let line_length: usize = line.len(); + let line_range = (current_index, current_index + line_length); + let end_line_size = end_line.len(); + body.push(DisplayLine::Source { + lineno: Some(current_line), + inline_marks: vec![], + line: DisplaySourceLine::Content { + text: line, + range: line_range, + end_line, + }, + annotations: vec![], + }); + + let leading_whitespace = line + .chars() + .take_while(|c| c.is_whitespace()) + .map(|c| { + match c { + // Tabs are displayed as 4 spaces + '\t' => 4, + _ => 1, + } + }) + .sum(); + if line.chars().any(|c| !c.is_whitespace()) { + whitespace_margin = min(whitespace_margin, leading_whitespace); + } + max_line_len = max(max_line_len, line_length); + + let line_start_index = line_range.0; + let line_end_index = line_range.1; + current_line += 1; + current_index += line_length + end_line_size; + + // It would be nice to use filter_drain here once it's stable. + annotations.retain(|(key, annotation)| { + let body_idx = idx; + let annotation_type = match annotation.level { + snippet::Level::Error => DisplayAnnotationType::None, + snippet::Level::Warning => DisplayAnnotationType::None, + _ => DisplayAnnotationType::from(annotation.level), + }; + let label_right = annotation.label.map_or(0, |label| label.len() + 1); + match annotation.range { + // This handles if the annotation is on the next line. We add + // the `end_line_size` to account for annotating the line end. + Range { start, .. } if start > line_end_index + end_line_size => true, + // This handles the case where an annotation is contained + // within the current line including any line-end characters. + Range { start, end } + if start >= line_start_index + // We add at least one to `line_end_index` to allow + // highlighting the end of a file + && end <= line_end_index + max(end_line_size, 1) => + { + if let DisplayLine::Source { + ref mut annotations, + .. + } = body[body_idx] + { + let annotation_start_col = line + [0..(start - line_start_index).min(line_length)] + .chars() + .map(|c| unicode_width::UnicodeWidthChar::width(c).unwrap_or(0)) + .sum::(); + let mut annotation_end_col = line + [0..(end - line_start_index).min(line_length)] + .chars() + .map(|c| unicode_width::UnicodeWidthChar::width(c).unwrap_or(0)) + .sum::(); + if annotation_start_col == annotation_end_col { + // At least highlight something + annotation_end_col += 1; + } + + span_left_margin = min(span_left_margin, annotation_start_col); + span_right_margin = max(span_right_margin, annotation_end_col); + label_right_margin = + max(label_right_margin, annotation_end_col + label_right); + + let range = (annotation_start_col, annotation_end_col); + annotations.push(DisplaySourceAnnotation { + annotation: Annotation { + annotation_type, + id: None, + label: format_label(annotation.label, None), + }, + range, + annotation_type: DisplayAnnotationType::from(annotation.level), + annotation_part: DisplayAnnotationPart::Standalone, + }); + } + false + } + // This handles the case where a multiline annotation starts + // somewhere on the current line, including any line-end chars + Range { start, end } + if start >= line_start_index + // The annotation can start on a line ending + && start <= line_end_index + end_line_size.saturating_sub(1) + && end > line_end_index => + { + if let DisplayLine::Source { + ref mut annotations, + .. + } = body[body_idx] + { + let annotation_start_col = line + [0..(start - line_start_index).min(line_length)] + .chars() + .map(|c| unicode_width::UnicodeWidthChar::width(c).unwrap_or(0)) + .sum::(); + let annotation_end_col = annotation_start_col + 1; + + span_left_margin = min(span_left_margin, annotation_start_col); + span_right_margin = max(span_right_margin, annotation_end_col); + label_right_margin = + max(label_right_margin, annotation_end_col + label_right); + + let range = (annotation_start_col, annotation_end_col); + annotations.push(DisplaySourceAnnotation { + annotation: Annotation { + annotation_type, + id: None, + label: vec![], + }, + range, + annotation_type: DisplayAnnotationType::from(annotation.level), + annotation_part: DisplayAnnotationPart::MultilineStart(current_depth), + }); + depth_map.insert(*key, current_depth); + current_depth += 1; + } + true + } + // This handles the case where a multiline annotation starts + // somewhere before this line and ends after it as well + Range { start, end } + if start < line_start_index && end > line_end_index + max(end_line_size, 1) => + { + if let DisplayLine::Source { + ref mut inline_marks, + .. + } = body[body_idx] + { + let depth = depth_map.get(key).cloned().unwrap_or_default(); + inline_marks.push(DisplayMark { + mark_type: DisplayMarkType::AnnotationThrough(depth), + annotation_type: DisplayAnnotationType::from(annotation.level), + }); + } + true + } + // This handles the case where a multiline annotation ends + // somewhere on the current line, including any line-end chars + Range { start, end } + if start < line_start_index + && end >= line_start_index + // We add at least one to `line_end_index` to allow + // highlighting the end of a file + && end <= line_end_index + max(end_line_size, 1) => + { + if let DisplayLine::Source { + ref mut annotations, + .. + } = body[body_idx] + { + let end_mark = line[0..(end - line_start_index).min(line_length)] + .chars() + .map(|c| unicode_width::UnicodeWidthChar::width(c).unwrap_or(0)) + .sum::() + .saturating_sub(1); + // If the annotation ends on a line-end character, we + // need to annotate one past the end of the line + let (end_mark, end_plus_one) = if end > line_end_index + // Special case for highlighting the end of a file + || (end == line_end_index + 1 && end_line_size == 0) + { + (end_mark + 1, end_mark + 2) + } else { + (end_mark, end_mark + 1) + }; + + span_left_margin = min(span_left_margin, end_mark); + span_right_margin = max(span_right_margin, end_plus_one); + label_right_margin = max(label_right_margin, end_plus_one + label_right); + + let range = (end_mark, end_plus_one); + let depth = depth_map.remove(key).unwrap_or(0); + annotations.push(DisplaySourceAnnotation { + annotation: Annotation { + annotation_type, + id: None, + label: format_label(annotation.label, None), + }, + range, + annotation_type: DisplayAnnotationType::from(annotation.level), + annotation_part: DisplayAnnotationPart::MultilineEnd(depth), + }); + } + false + } + _ => true, + } + }); + // Reset the depth counter, but only after we've processed all + // annotations for a given line. + let max = depth_map.len(); + if current_depth > max { + current_depth = max; + } + } + + if snippet.fold { + body = fold_body(body); + } + + if need_empty_header { + body.insert( + 0, + DisplayLine::Source { + lineno: None, + inline_marks: vec![], + line: DisplaySourceLine::Empty, + annotations: vec![], + }, + ); + } + + if has_footer { + body.push(DisplayLine::Source { + lineno: None, + inline_marks: vec![], + line: DisplaySourceLine::Empty, + annotations: vec![], + }); + } else if let Some(DisplayLine::Source { .. }) = body.last() { + body.push(DisplayLine::Source { + lineno: None, + inline_marks: vec![], + line: DisplaySourceLine::Empty, + annotations: vec![], + }); + } + let max_line_num_len = if anonymized_line_numbers { + ANONYMIZED_LINE_NUM.len() + } else { + current_line.to_string().len() + }; + + let width_offset = 3 + max_line_num_len; + + if span_left_margin == usize::MAX { + span_left_margin = 0; + } + + let margin = Margin::new( + whitespace_margin, + span_left_margin, + span_right_margin, + label_right_margin, + term_width.saturating_sub(width_offset), + max_line_len, + ); + + DisplaySet { + display_lines: body, + margin, + } +} + +#[inline] +fn annotation_type_str(annotation_type: &DisplayAnnotationType) -> &'static str { + match annotation_type { + DisplayAnnotationType::Error => ERROR_TXT, + DisplayAnnotationType::Help => HELP_TXT, + DisplayAnnotationType::Info => INFO_TXT, + DisplayAnnotationType::Note => NOTE_TXT, + DisplayAnnotationType::Warning => WARNING_TXT, + DisplayAnnotationType::None => "", + } +} + +fn annotation_type_len(annotation_type: &DisplayAnnotationType) -> usize { + match annotation_type { + DisplayAnnotationType::Error => ERROR_TXT.len(), + DisplayAnnotationType::Help => HELP_TXT.len(), + DisplayAnnotationType::Info => INFO_TXT.len(), + DisplayAnnotationType::Note => NOTE_TXT.len(), + DisplayAnnotationType::Warning => WARNING_TXT.len(), + DisplayAnnotationType::None => 0, + } +} + +fn get_annotation_style<'a>( + annotation_type: &DisplayAnnotationType, + stylesheet: &'a Stylesheet, +) -> &'a Style { + match annotation_type { + DisplayAnnotationType::Error => stylesheet.error(), + DisplayAnnotationType::Warning => stylesheet.warning(), + DisplayAnnotationType::Info => stylesheet.info(), + DisplayAnnotationType::Note => stylesheet.note(), + DisplayAnnotationType::Help => stylesheet.help(), + DisplayAnnotationType::None => stylesheet.none(), + } +} + +#[inline] +fn is_annotation_empty(annotation: &Annotation<'_>) -> bool { + annotation + .label + .iter() + .all(|fragment| fragment.content.is_empty()) +} + +// We replace some characters so the CLI output is always consistent and underlines aligned. +const OUTPUT_REPLACEMENTS: &[(char, &str)] = &[ + ('\t', " "), // We do our own tab replacement + ('\u{200D}', ""), // Replace ZWJ with nothing for consistent terminal output of grapheme clusters. + ('\u{202A}', ""), // The following unicode text flow control characters are inconsistently + ('\u{202B}', ""), // supported across CLIs and can cause confusion due to the bytes on disk + ('\u{202D}', ""), // not corresponding to the visible source code, so we replace them always. + ('\u{202E}', ""), + ('\u{2066}', ""), + ('\u{2067}', ""), + ('\u{2068}', ""), + ('\u{202C}', ""), + ('\u{2069}', ""), +]; + +fn normalize_whitespace(str: &str) -> String { + let mut s = str.to_owned(); + for (c, replacement) in OUTPUT_REPLACEMENTS { + s = s.replace(*c, replacement); + } + s +} + +fn overlaps( + a1: &DisplaySourceAnnotation<'_>, + a2: &DisplaySourceAnnotation<'_>, + padding: usize, +) -> bool { + (a2.range.0..a2.range.1).contains(&a1.range.0) + || (a1.range.0..a1.range.1 + padding).contains(&a2.range.0) +} + +fn format_inline_marks( + line: usize, + inline_marks: &[DisplayMark], + lineno_width: usize, + stylesheet: &Stylesheet, + buf: &mut StyledBuffer, +) -> fmt::Result { + for mark in inline_marks.iter() { + let annotation_style = get_annotation_style(&mark.annotation_type, stylesheet); + match mark.mark_type { + DisplayMarkType::AnnotationThrough(depth) => { + buf.putc(line, 3 + lineno_width + depth, '|', *annotation_style); + } + }; + } + Ok(()) +} diff --git a/crates/ruff_annotate_snippets/src/renderer/margin.rs b/crates/ruff_annotate_snippets/src/renderer/margin.rs new file mode 100644 index 0000000000000..c484416610782 --- /dev/null +++ b/crates/ruff_annotate_snippets/src/renderer/margin.rs @@ -0,0 +1,119 @@ +use std::cmp::{max, min}; + +const ELLIPSIS_PASSING: usize = 6; +const LONG_WHITESPACE: usize = 20; +const LONG_WHITESPACE_PADDING: usize = 4; + +#[derive(Clone, Copy, Debug, PartialEq)] +pub(crate) struct Margin { + /// The available whitespace in the left that can be consumed when centering. + whitespace_left: usize, + /// The column of the beginning of left-most span. + span_left: usize, + /// The column of the end of right-most span. + span_right: usize, + /// The beginning of the line to be displayed. + computed_left: usize, + /// The end of the line to be displayed. + computed_right: usize, + /// The current width of the terminal. 140 by default and in tests. + term_width: usize, + /// The end column of a span label, including the span. Doesn't account for labels not in the + /// same line as the span. + label_right: usize, +} + +impl Margin { + pub(crate) fn new( + whitespace_left: usize, + span_left: usize, + span_right: usize, + label_right: usize, + term_width: usize, + max_line_len: usize, + ) -> Self { + // The 6 is padding to give a bit of room for `...` when displaying: + // ``` + // error: message + // --> file.rs:16:58 + // | + // 16 | ... fn foo(self) -> Self::Bar { + // | ^^^^^^^^^ + // ``` + + let mut m = Margin { + whitespace_left: whitespace_left.saturating_sub(ELLIPSIS_PASSING), + span_left: span_left.saturating_sub(ELLIPSIS_PASSING), + span_right: span_right + ELLIPSIS_PASSING, + computed_left: 0, + computed_right: 0, + term_width, + label_right: label_right + ELLIPSIS_PASSING, + }; + m.compute(max_line_len); + m + } + + pub(crate) fn was_cut_left(&self) -> bool { + self.computed_left > 0 + } + + pub(crate) fn was_cut_right(&self, line_len: usize) -> bool { + let right = + if self.computed_right == self.span_right || self.computed_right == self.label_right { + // Account for the "..." padding given above. Otherwise we end up with code lines that + // do fit but end in "..." as if they were trimmed. + self.computed_right - ELLIPSIS_PASSING + } else { + self.computed_right + }; + right < line_len && self.computed_left + self.term_width < line_len + } + + fn compute(&mut self, max_line_len: usize) { + // When there's a lot of whitespace (>20), we want to trim it as it is useless. + self.computed_left = if self.whitespace_left > LONG_WHITESPACE { + self.whitespace_left - (LONG_WHITESPACE - LONG_WHITESPACE_PADDING) // We want some padding. + } else { + 0 + }; + // We want to show as much as possible, max_line_len is the right-most boundary for the + // relevant code. + self.computed_right = max(max_line_len, self.computed_left); + + if self.computed_right - self.computed_left > self.term_width { + // Trimming only whitespace isn't enough, let's get craftier. + if self.label_right - self.whitespace_left <= self.term_width { + // Attempt to fit the code window only trimming whitespace. + self.computed_left = self.whitespace_left; + self.computed_right = self.computed_left + self.term_width; + } else if self.label_right - self.span_left <= self.term_width { + // Attempt to fit the code window considering only the spans and labels. + let padding_left = (self.term_width - (self.label_right - self.span_left)) / 2; + self.computed_left = self.span_left.saturating_sub(padding_left); + self.computed_right = self.computed_left + self.term_width; + } else if self.span_right - self.span_left <= self.term_width { + // Attempt to fit the code window considering the spans and labels plus padding. + let padding_left = (self.term_width - (self.span_right - self.span_left)) / 5 * 2; + self.computed_left = self.span_left.saturating_sub(padding_left); + self.computed_right = self.computed_left + self.term_width; + } else { + // Mostly give up but still don't show the full line. + self.computed_left = self.span_left; + self.computed_right = self.span_right; + } + } + } + + pub(crate) fn left(&self, line_len: usize) -> usize { + min(self.computed_left, line_len) + } + + pub(crate) fn right(&self, line_len: usize) -> usize { + if line_len.saturating_sub(self.computed_left) <= self.term_width { + line_len + } else { + min(line_len, self.computed_right) + } + } +} diff --git a/crates/ruff_annotate_snippets/src/renderer/mod.rs b/crates/ruff_annotate_snippets/src/renderer/mod.rs new file mode 100644 index 0000000000000..52ec9ad331e9a --- /dev/null +++ b/crates/ruff_annotate_snippets/src/renderer/mod.rs @@ -0,0 +1,163 @@ +//! The renderer for [`Message`]s +//! +//! # Example +//! ``` +//! use ruff_annotate_snippets::{Renderer, Snippet, Level}; +//! let snippet = Level::Error.title("mismatched types") +//! .snippet(Snippet::source("Foo").line_start(51).origin("src/format.rs")) +//! .snippet(Snippet::source("Faa").line_start(129).origin("src/display.rs")); +//! +//! let renderer = Renderer::styled(); +//! println!("{}", renderer.render(snippet)); + +mod display_list; +mod margin; +mod styled_buffer; +pub(crate) mod stylesheet; + +use crate::snippet::Message; +pub use anstyle::*; +use display_list::DisplayList; +use margin::Margin; +use std::fmt::Display; +use stylesheet::Stylesheet; + +pub const DEFAULT_TERM_WIDTH: usize = 140; + +/// A renderer for [`Message`]s +#[derive(Clone, Debug)] +pub struct Renderer { + anonymized_line_numbers: bool, + term_width: usize, + stylesheet: Stylesheet, +} + +impl Renderer { + /// No terminal styling + pub const fn plain() -> Self { + Self { + anonymized_line_numbers: false, + term_width: DEFAULT_TERM_WIDTH, + stylesheet: Stylesheet::plain(), + } + } + + /// Default terminal styling + /// + /// # Note + /// When testing styled terminal output, see the [`testing-colors` feature](crate#features) + pub const fn styled() -> Self { + const USE_WINDOWS_COLORS: bool = cfg!(windows) && !cfg!(feature = "testing-colors"); + const BRIGHT_BLUE: Style = if USE_WINDOWS_COLORS { + AnsiColor::BrightCyan.on_default() + } else { + AnsiColor::BrightBlue.on_default() + }; + Self { + stylesheet: Stylesheet { + error: AnsiColor::BrightRed.on_default().effects(Effects::BOLD), + warning: if USE_WINDOWS_COLORS { + AnsiColor::BrightYellow.on_default() + } else { + AnsiColor::Yellow.on_default() + } + .effects(Effects::BOLD), + info: BRIGHT_BLUE.effects(Effects::BOLD), + note: AnsiColor::BrightGreen.on_default().effects(Effects::BOLD), + help: AnsiColor::BrightCyan.on_default().effects(Effects::BOLD), + line_no: BRIGHT_BLUE.effects(Effects::BOLD), + emphasis: if USE_WINDOWS_COLORS { + AnsiColor::BrightWhite.on_default() + } else { + Style::new() + } + .effects(Effects::BOLD), + none: Style::new(), + }, + ..Self::plain() + } + } + + /// Anonymize line numbers + /// + /// This enables (or disables) line number anonymization. When enabled, line numbers are replaced + /// with `LL`. + /// + /// # Example + /// + /// ```text + /// --> $DIR/whitespace-trimming.rs:4:193 + /// | + /// LL | ... let _: () = 42; + /// | ^^ expected (), found integer + /// | + /// ``` + pub const fn anonymized_line_numbers(mut self, anonymized_line_numbers: bool) -> Self { + self.anonymized_line_numbers = anonymized_line_numbers; + self + } + + // Set the terminal width + pub const fn term_width(mut self, term_width: usize) -> Self { + self.term_width = term_width; + self + } + + /// Set the output style for `error` + pub const fn error(mut self, style: Style) -> Self { + self.stylesheet.error = style; + self + } + + /// Set the output style for `warning` + pub const fn warning(mut self, style: Style) -> Self { + self.stylesheet.warning = style; + self + } + + /// Set the output style for `info` + pub const fn info(mut self, style: Style) -> Self { + self.stylesheet.info = style; + self + } + + /// Set the output style for `note` + pub const fn note(mut self, style: Style) -> Self { + self.stylesheet.note = style; + self + } + + /// Set the output style for `help` + pub const fn help(mut self, style: Style) -> Self { + self.stylesheet.help = style; + self + } + + /// Set the output style for line numbers + pub const fn line_no(mut self, style: Style) -> Self { + self.stylesheet.line_no = style; + self + } + + /// Set the output style for emphasis + pub const fn emphasis(mut self, style: Style) -> Self { + self.stylesheet.emphasis = style; + self + } + + /// Set the output style for none + pub const fn none(mut self, style: Style) -> Self { + self.stylesheet.none = style; + self + } + + /// Render a snippet into a `Display`able object + pub fn render<'a>(&'a self, msg: Message<'a>) -> impl Display + 'a { + DisplayList::new( + msg, + &self.stylesheet, + self.anonymized_line_numbers, + self.term_width, + ) + } +} diff --git a/crates/ruff_annotate_snippets/src/renderer/styled_buffer.rs b/crates/ruff_annotate_snippets/src/renderer/styled_buffer.rs new file mode 100644 index 0000000000000..ec834e1bce915 --- /dev/null +++ b/crates/ruff_annotate_snippets/src/renderer/styled_buffer.rs @@ -0,0 +1,97 @@ +//! Adapted from [styled_buffer] +//! +//! [styled_buffer]: https://github.com/rust-lang/rust/blob/894f7a4ba6554d3797404bbf550d9919df060b97/compiler/rustc_errors/src/styled_buffer.rs + +use crate::renderer::stylesheet::Stylesheet; +use anstyle::Style; +use std::fmt; +use std::fmt::Write; + +#[derive(Debug)] +pub(crate) struct StyledBuffer { + lines: Vec>, +} + +#[derive(Clone, Copy, Debug, PartialEq)] +pub(crate) struct StyledChar { + ch: char, + style: Style, +} + +impl StyledChar { + pub(crate) const SPACE: Self = StyledChar::new(' ', Style::new()); + + pub(crate) const fn new(ch: char, style: Style) -> StyledChar { + StyledChar { ch, style } + } +} + +impl StyledBuffer { + pub(crate) fn new() -> StyledBuffer { + StyledBuffer { lines: vec![] } + } + + fn ensure_lines(&mut self, line: usize) { + if line >= self.lines.len() { + self.lines.resize(line + 1, Vec::new()); + } + } + + pub(crate) fn render(&self, stylesheet: &Stylesheet) -> Result { + let mut str = String::new(); + for (i, line) in self.lines.iter().enumerate() { + let mut current_style = stylesheet.none; + for ch in line { + if ch.style != current_style { + if !line.is_empty() { + write!(str, "{}", current_style.render_reset())?; + } + current_style = ch.style; + write!(str, "{}", current_style.render())?; + } + write!(str, "{}", ch.ch)?; + } + write!(str, "{}", current_style.render_reset())?; + if i != self.lines.len() - 1 { + writeln!(str)?; + } + } + Ok(str) + } + + /// Sets `chr` with `style` for given `line`, `col`. + /// If `line` does not exist in our buffer, adds empty lines up to the given + /// and fills the last line with unstyled whitespace. + pub(crate) fn putc(&mut self, line: usize, col: usize, chr: char, style: Style) { + self.ensure_lines(line); + if col >= self.lines[line].len() { + self.lines[line].resize(col + 1, StyledChar::SPACE); + } + self.lines[line][col] = StyledChar::new(chr, style); + } + + /// Sets `string` with `style` for given `line`, starting from `col`. + /// If `line` does not exist in our buffer, adds empty lines up to the given + /// and fills the last line with unstyled whitespace. + pub(crate) fn puts(&mut self, line: usize, col: usize, string: &str, style: Style) { + let mut n = col; + for c in string.chars() { + self.putc(line, n, c, style); + n += 1; + } + } + /// For given `line` inserts `string` with `style` after old content of that line, + /// adding lines if needed + pub(crate) fn append(&mut self, line: usize, string: &str, style: Style) { + if line >= self.lines.len() { + self.puts(line, 0, string, style); + } else { + let col = self.lines[line].len(); + self.puts(line, col, string, style); + } + } + + pub(crate) fn num_lines(&self) -> usize { + self.lines.len() + } +} diff --git a/crates/ruff_annotate_snippets/src/renderer/stylesheet.rs b/crates/ruff_annotate_snippets/src/renderer/stylesheet.rs new file mode 100644 index 0000000000000..ee1ab93764c4c --- /dev/null +++ b/crates/ruff_annotate_snippets/src/renderer/stylesheet.rs @@ -0,0 +1,68 @@ +use anstyle::Style; + +#[derive(Clone, Copy, Debug)] +pub(crate) struct Stylesheet { + pub(crate) error: Style, + pub(crate) warning: Style, + pub(crate) info: Style, + pub(crate) note: Style, + pub(crate) help: Style, + pub(crate) line_no: Style, + pub(crate) emphasis: Style, + pub(crate) none: Style, +} + +impl Default for Stylesheet { + fn default() -> Self { + Self::plain() + } +} + +impl Stylesheet { + pub(crate) const fn plain() -> Self { + Self { + error: Style::new(), + warning: Style::new(), + info: Style::new(), + note: Style::new(), + help: Style::new(), + line_no: Style::new(), + emphasis: Style::new(), + none: Style::new(), + } + } +} + +impl Stylesheet { + pub(crate) fn error(&self) -> &Style { + &self.error + } + + pub(crate) fn warning(&self) -> &Style { + &self.warning + } + + pub(crate) fn info(&self) -> &Style { + &self.info + } + + pub(crate) fn note(&self) -> &Style { + &self.note + } + + pub(crate) fn help(&self) -> &Style { + &self.help + } + + pub(crate) fn line_no(&self) -> &Style { + &self.line_no + } + + pub(crate) fn emphasis(&self) -> &Style { + &self.emphasis + } + + pub(crate) fn none(&self) -> &Style { + &self.none + } +} diff --git a/crates/ruff_annotate_snippets/src/snippet.rs b/crates/ruff_annotate_snippets/src/snippet.rs new file mode 100644 index 0000000000000..9a1394604b859 --- /dev/null +++ b/crates/ruff_annotate_snippets/src/snippet.rs @@ -0,0 +1,157 @@ +//! Structures used as an input for the library. +//! +//! Example: +//! +//! ``` +//! use ruff_annotate_snippets::*; +//! +//! Level::Error.title("mismatched types") +//! .snippet(Snippet::source("Foo").line_start(51).origin("src/format.rs")) +//! .snippet(Snippet::source("Faa").line_start(129).origin("src/display.rs")); +//! ``` + +use std::ops::Range; + +/// Primary structure provided for formatting +/// +/// See [`Level::title`] to create a [`Message`] +#[derive(Debug)] +pub struct Message<'a> { + pub(crate) level: Level, + pub(crate) id: Option<&'a str>, + pub(crate) title: &'a str, + pub(crate) snippets: Vec>, + pub(crate) footer: Vec>, +} + +impl<'a> Message<'a> { + pub fn id(mut self, id: &'a str) -> Self { + self.id = Some(id); + self + } + + pub fn snippet(mut self, slice: Snippet<'a>) -> Self { + self.snippets.push(slice); + self + } + + pub fn snippets(mut self, slice: impl IntoIterator>) -> Self { + self.snippets.extend(slice); + self + } + + pub fn footer(mut self, footer: Message<'a>) -> Self { + self.footer.push(footer); + self + } + + pub fn footers(mut self, footer: impl IntoIterator>) -> Self { + self.footer.extend(footer); + self + } +} + +/// Structure containing the slice of text to be annotated and +/// basic information about the location of the slice. +/// +/// One `Snippet` is meant to represent a single, continuous, +/// slice of source code that you want to annotate. +#[derive(Debug)] +pub struct Snippet<'a> { + pub(crate) origin: Option<&'a str>, + pub(crate) line_start: usize, + + pub(crate) source: &'a str, + pub(crate) annotations: Vec>, + + pub(crate) fold: bool, +} + +impl<'a> Snippet<'a> { + pub fn source(source: &'a str) -> Self { + Self { + origin: None, + line_start: 1, + source, + annotations: vec![], + fold: false, + } + } + + pub fn line_start(mut self, line_start: usize) -> Self { + self.line_start = line_start; + self + } + + pub fn origin(mut self, origin: &'a str) -> Self { + self.origin = Some(origin); + self + } + + pub fn annotation(mut self, annotation: Annotation<'a>) -> Self { + self.annotations.push(annotation); + self + } + + pub fn annotations(mut self, annotation: impl IntoIterator>) -> Self { + self.annotations.extend(annotation); + self + } + + /// Hide lines without [`Annotation`]s + pub fn fold(mut self, fold: bool) -> Self { + self.fold = fold; + self + } +} + +/// An annotation for a [`Snippet`]. +/// +/// See [`Level::span`] to create a [`Annotation`] +#[derive(Debug)] +pub struct Annotation<'a> { + /// The byte range of the annotation in the `source` string + pub(crate) range: Range, + pub(crate) label: Option<&'a str>, + pub(crate) level: Level, +} + +impl<'a> Annotation<'a> { + pub fn label(mut self, label: &'a str) -> Self { + self.label = Some(label); + self + } +} + +/// Types of annotations. +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum Level { + /// Error annotations are displayed using red color and "^" character. + Error, + /// Warning annotations are displayed using blue color and "-" character. + Warning, + Info, + Note, + Help, +} + +impl Level { + pub fn title(self, title: &str) -> Message<'_> { + Message { + level: self, + id: None, + title, + snippets: vec![], + footer: vec![], + } + } + + /// Create a [`Annotation`] with the given span for a [`Snippet`] + pub fn span<'a>(self, span: Range) -> Annotation<'a> { + Annotation { + range: span, + label: None, + level: self, + } + } +} diff --git a/crates/ruff_annotate_snippets/tests/examples.rs b/crates/ruff_annotate_snippets/tests/examples.rs new file mode 100644 index 0000000000000..b6576629f91ba --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/examples.rs @@ -0,0 +1,37 @@ +#[test] +fn expected_type() { + let target = "expected_type"; + let expected = snapbox::file!["../examples/expected_type.svg": TermSvg]; + assert_example(target, expected); +} + +#[test] +fn footer() { + let target = "footer"; + let expected = snapbox::file!["../examples/footer.svg": TermSvg]; + assert_example(target, expected); +} + +#[test] +fn format() { + let target = "format"; + let expected = snapbox::file!["../examples/format.svg": TermSvg]; + assert_example(target, expected); +} + +#[test] +fn multislice() { + let target = "multislice"; + let expected = snapbox::file!["../examples/multislice.svg": TermSvg]; + assert_example(target, expected); +} + +#[track_caller] +fn assert_example(target: &str, expected: snapbox::Data) { + let bin_path = snapbox::cmd::compile_example(target, ["--features=testing-colors"]).unwrap(); + snapbox::cmd::Command::new(bin_path) + .env("CLICOLOR_FORCE", "1") + .assert() + .success() + .stdout_eq(expected.raw()); +} diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/ann_eof.svg b/crates/ruff_annotate_snippets/tests/fixtures/color/ann_eof.svg new file mode 100644 index 0000000000000..bb12aecf29146 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/ann_eof.svg @@ -0,0 +1,36 @@ + + + + + + + error: expected `.`, `=` + + --> Cargo.toml:1:5 + + | + + 1 | asdf + + | ^ + + | + + + + diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/ann_eof.toml b/crates/ruff_annotate_snippets/tests/fixtures/color/ann_eof.toml new file mode 100644 index 0000000000000..cee5f0fbcd4ae --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/ann_eof.toml @@ -0,0 +1,15 @@ +[message] +level = "Error" +title = "expected `.`, `=`" + +[[message.snippets]] +source = "asdf" +line_start = 1 +origin = "Cargo.toml" +[[message.snippets.annotations]] +label = "" +level = "Error" +range = [4, 4] + +[renderer] +color = true diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/ann_insertion.svg b/crates/ruff_annotate_snippets/tests/fixtures/color/ann_insertion.svg new file mode 100644 index 0000000000000..1f4b6a24a6744 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/ann_insertion.svg @@ -0,0 +1,36 @@ + + + + + + + error: expected `.`, `=` + + --> Cargo.toml:1:3 + + | + + 1 | asf + + | ^ 'd' belongs here + + | + + + + diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/ann_insertion.toml b/crates/ruff_annotate_snippets/tests/fixtures/color/ann_insertion.toml new file mode 100644 index 0000000000000..bf7411ef49c54 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/ann_insertion.toml @@ -0,0 +1,15 @@ +[message] +level = "Error" +title = "expected `.`, `=`" + +[[message.snippets]] +source = "asf" +line_start = 1 +origin = "Cargo.toml" +[[message.snippets.annotations]] +label = "'d' belongs here" +level = "Error" +range = [2, 2] + +[renderer] +color = true diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/ann_multiline.svg b/crates/ruff_annotate_snippets/tests/fixtures/color/ann_multiline.svg new file mode 100644 index 0000000000000..913069149d955 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/ann_multiline.svg @@ -0,0 +1,42 @@ + + + + + + + error[E0027]: pattern does not mention fields `lineno`, `content` + + --> src/display_list.rs:139:32 + + | + + 139 | if let DisplayLine::Source { + + | ________________________________^ + + 140 | | ref mut inline_marks, + + 141 | | } = body[body_idx] + + | |_________________________^ missing fields `lineno`, `content` + + | + + + + diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/ann_multiline.toml b/crates/ruff_annotate_snippets/tests/fixtures/color/ann_multiline.toml new file mode 100644 index 0000000000000..9d8c30f9ec5b6 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/ann_multiline.toml @@ -0,0 +1,21 @@ +[message] +level = "Error" +id = "E0027" +title = "pattern does not mention fields `lineno`, `content`" + +[[message.snippets]] +source = """ + if let DisplayLine::Source { + ref mut inline_marks, + } = body[body_idx] +""" +line_start = 139 +origin = "src/display_list.rs" +fold = false +[[message.snippets.annotations]] +label = "missing fields `lineno`, `content`" +level = "Error" +range = [31, 128] + +[renderer] +color = true diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/ann_multiline2.svg b/crates/ruff_annotate_snippets/tests/fixtures/color/ann_multiline2.svg new file mode 100644 index 0000000000000..97948a47a9218 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/ann_multiline2.svg @@ -0,0 +1,40 @@ + + + + + + + error[E####]: spacing error found + + --> foo.txt:26:12 + + | + + 26 | This is an example + + | ^^^^^^^ this should not be on separate lines + + 27 | of an edge case of an annotation overflowing + + 28 | to exactly one character on next line. + + | + + + + diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/ann_multiline2.toml b/crates/ruff_annotate_snippets/tests/fixtures/color/ann_multiline2.toml new file mode 100644 index 0000000000000..259d94b421ed0 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/ann_multiline2.toml @@ -0,0 +1,21 @@ +[message] +level = "Error" +id = "E####" +title = "spacing error found" + +[[message.snippets]] +source = """ +This is an example +of an edge case of an annotation overflowing +to exactly one character on next line. +""" +line_start = 26 +origin = "foo.txt" +fold = false +[[message.snippets.annotations]] +label = "this should not be on separate lines" +level = "Error" +range = [11, 19] + +[renderer] +color = true diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/ann_removed_nl.svg b/crates/ruff_annotate_snippets/tests/fixtures/color/ann_removed_nl.svg new file mode 100644 index 0000000000000..bb12aecf29146 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/ann_removed_nl.svg @@ -0,0 +1,36 @@ + + + + + + + error: expected `.`, `=` + + --> Cargo.toml:1:5 + + | + + 1 | asdf + + | ^ + + | + + + + diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/ann_removed_nl.toml b/crates/ruff_annotate_snippets/tests/fixtures/color/ann_removed_nl.toml new file mode 100644 index 0000000000000..36f74ef6da08a --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/ann_removed_nl.toml @@ -0,0 +1,15 @@ +[message] +level = "Error" +title = "expected `.`, `=`" + +[[message.snippets]] +source = "asdf" +line_start = 1 +origin = "Cargo.toml" +[[message.snippets.annotations]] +label = "" +level = "Error" +range = [4, 5] + +[renderer] +color = true diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/ensure-emoji-highlight-width.svg b/crates/ruff_annotate_snippets/tests/fixtures/color/ensure-emoji-highlight-width.svg new file mode 100644 index 0000000000000..e5646e61ada11 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/ensure-emoji-highlight-width.svg @@ -0,0 +1,36 @@ + + + + + + + error: invalid character ` ` in package name: `haha this isn't a valid name 🐛`, characters must be Unicode XID characters (numbers, `-`, `_`, or most letters) + + --> <file>:7:1 + + | + + 7 | "haha this isn't a valid name 🐛" = { package = "libc", version = "0.1" } + + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + | + + + + diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/ensure-emoji-highlight-width.toml b/crates/ruff_annotate_snippets/tests/fixtures/color/ensure-emoji-highlight-width.toml new file mode 100644 index 0000000000000..52168b480b8eb --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/ensure-emoji-highlight-width.toml @@ -0,0 +1,18 @@ +[message] +title = "invalid character ` ` in package name: `haha this isn't a valid name 🐛`, characters must be Unicode XID characters (numbers, `-`, `_`, or most letters)" +level = "Error" + + +[[message.snippets]] +source = """ +"haha this isn't a valid name 🐛" = { package = "libc", version = "0.1" } +""" +line_start = 7 +origin = "" +[[message.snippets.annotations]] +label = "" +level = "Error" +range = [0, 35] + +[renderer] +color = true diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/fold_ann_multiline.svg b/crates/ruff_annotate_snippets/tests/fixtures/color/fold_ann_multiline.svg new file mode 100644 index 0000000000000..6a89c4f75f1b8 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/fold_ann_multiline.svg @@ -0,0 +1,49 @@ + + + + + + + error[E0308]: mismatched types + + --> src/format.rs:51:6 + + | + + 51 | ) -> Option<String> { + + | -------------- expected `std::option::Option<std::string::String>` because of return type + + 52 | / for ann in annotations { + + 53 | | match (ann.range.0, ann.range.1) { + + ... | + + 71 | | } + + 72 | | } + + | |_____^ expected enum `std::option::Option`, found () + + | + + + + diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/fold_ann_multiline.toml b/crates/ruff_annotate_snippets/tests/fixtures/color/fold_ann_multiline.toml new file mode 100644 index 0000000000000..80edfb552afcf --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/fold_ann_multiline.toml @@ -0,0 +1,44 @@ +[message] +level = "Error" +id = "E0308" +title = "mismatched types" + +[[message.snippets]] +source = """ +) -> Option { + for ann in annotations { + match (ann.range.0, ann.range.1) { + (None, None) => continue, + (Some(start), Some(end)) if start > end_index || end < start_index => continue, + (Some(start), Some(end)) if start >= start_index && end <= end_index => { + let label = if let Some(ref label) = ann.label { + format!(" {}", label) + } else { + String::from("") + }; + + return Some(format!( + "{}{}{}", + " ".repeat(start - start_index), + "^".repeat(end - start), + label + )); + } + _ => continue, + } + } +""" +line_start = 51 +origin = "src/format.rs" +fold = true +[[message.snippets.annotations]] +label = "expected `std::option::Option` because of return type" +level = "Warning" +range = [5, 19] +[[message.snippets.annotations]] +label = "expected enum `std::option::Option`, found ()" +level = "Error" +range = [22, 766] + +[renderer] +color = true diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/fold_bad_origin_line.svg b/crates/ruff_annotate_snippets/tests/fixtures/color/fold_bad_origin_line.svg new file mode 100644 index 0000000000000..23f1b646e4641 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/fold_bad_origin_line.svg @@ -0,0 +1,37 @@ + + + + + + + error + + --> path/to/error.rs:3:1 + + | + + 3 | invalid syntax + + | -------------- error here + + | + + + + diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/fold_bad_origin_line.toml b/crates/ruff_annotate_snippets/tests/fixtures/color/fold_bad_origin_line.toml new file mode 100644 index 0000000000000..3e40137ac61d9 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/fold_bad_origin_line.toml @@ -0,0 +1,20 @@ +[message] +level = "Error" +title = "" + +[[message.snippets]] +source = """ + + +invalid syntax +""" +line_start = 1 +origin = "path/to/error.rs" +fold = true +[[message.snippets.annotations]] +label = "error here" +level = "Warning" +range = [2,16] + +[renderer] +color = true diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/fold_leading.svg b/crates/ruff_annotate_snippets/tests/fixtures/color/fold_leading.svg new file mode 100644 index 0000000000000..e69965e98ad15 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/fold_leading.svg @@ -0,0 +1,36 @@ + + + + + + + error[E0308]: invalid type: integer `20`, expected a bool + + --> Cargo.toml:11:13 + + | + + 11 | workspace = 20 + + | ^^ + + | + + + + diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/fold_leading.toml b/crates/ruff_annotate_snippets/tests/fixtures/color/fold_leading.toml new file mode 100644 index 0000000000000..90c6c8c4a628f --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/fold_leading.toml @@ -0,0 +1,29 @@ +[message] +level = "Error" +id = "E0308" +title = "invalid type: integer `20`, expected a bool" + +[[message.snippets]] +source = """ +[workspace] + +[package] +name = "hello" +version = "1.0.0" +license = "MIT" +rust-version = "1.70" +edition = "2021" + +[lints] +workspace = 20 +""" +line_start = 1 +origin = "Cargo.toml" +fold = true +[[message.snippets.annotations]] +label = "" +level = "Error" +range = [132, 134] + +[renderer] +color = true diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/fold_trailing.svg b/crates/ruff_annotate_snippets/tests/fixtures/color/fold_trailing.svg new file mode 100644 index 0000000000000..41bf7c7959806 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/fold_trailing.svg @@ -0,0 +1,36 @@ + + + + + + + error[E0308]: invalid type: integer `20`, expected a lints table + + --> Cargo.toml:1:9 + + | + + 1 | lints = 20 + + | ^^ + + | + + + + diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/fold_trailing.toml b/crates/ruff_annotate_snippets/tests/fixtures/color/fold_trailing.toml new file mode 100644 index 0000000000000..10b2240c13f3c --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/fold_trailing.toml @@ -0,0 +1,28 @@ +[message] +level = "Error" +id = "E0308" +title = "invalid type: integer `20`, expected a lints table" + +[[message.snippets]] +source = """ +lints = 20 + +[workspace] + +[package] +name = "hello" +version = "1.0.0" +license = "MIT" +rust-version = "1.70" +edition = "2021" +""" +line_start = 1 +origin = "Cargo.toml" +fold = true +[[message.snippets.annotations]] +label = "" +level = "Error" +range = [8, 10] + +[renderer] +color = true diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/issue_9.svg b/crates/ruff_annotate_snippets/tests/fixtures/color/issue_9.svg new file mode 100644 index 0000000000000..80b891e0affd1 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/issue_9.svg @@ -0,0 +1,49 @@ + + + + + + + error: expected one of `.`, `;`, `?`, or an operator, found `for` + + --> /code/rust/src/test/ui/annotate-snippet/suggestion.rs:4:5 + + | + + 4 | let x = vec![1]; + + | - move occurs because `x` has type `std::vec::Vec<i32>`, which does not implement the `Copy` trait + + | + + 7 | let y = x; + + | - value moved here + + | + + 9 | x; + + | ^ value used here after move + + | + + + + diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/issue_9.toml b/crates/ruff_annotate_snippets/tests/fixtures/color/issue_9.toml new file mode 100644 index 0000000000000..9de1753402794 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/issue_9.toml @@ -0,0 +1,31 @@ +[message] +level = "Error" +title = "expected one of `.`, `;`, `?`, or an operator, found `for`" + +[[message.snippets]] +source = "let x = vec![1];" +line_start = 4 +origin = "/code/rust/src/test/ui/annotate-snippet/suggestion.rs" +[[message.snippets.annotations]] +label = "move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait" +level = "Warning" +range = [4, 5] + +[[message.snippets]] +source = "let y = x;" +line_start = 7 +[[message.snippets.annotations]] +label = "value moved here" +level = "Warning" +range = [8, 9] + +[[message.snippets]] +source = "x;" +line_start = 9 +[[message.snippets.annotations]] +label = "value used here after move" +level = "Error" +range = [0, 1] + +[renderer] +color = true diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/multiple_annotations.svg b/crates/ruff_annotate_snippets/tests/fixtures/color/multiple_annotations.svg new file mode 100644 index 0000000000000..84f474950c587 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/multiple_annotations.svg @@ -0,0 +1,54 @@ + + + + + + + error + + | + + 96 | fn add_title_line(result: &mut Vec<String>, main_annotation: Option<&Annotation>) { + + 97 | if let Some(annotation) = main_annotation { + + | ^^^^^^^^^^ Variable defined here + + 98 | result.push(format_title_line( + + 99 | &annotation.annotation_type, + + | ^^^^^^^^^^ Referenced here + + 100 | None, + + 101 | &annotation.label, + + | ^^^^^^^^^^ Referenced again here + + 102 | )); + + 103 | } + + 104 | } + + | + + + + diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/multiple_annotations.toml b/crates/ruff_annotate_snippets/tests/fixtures/color/multiple_annotations.toml new file mode 100644 index 0000000000000..824c53054cd6b --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/multiple_annotations.toml @@ -0,0 +1,32 @@ +[message] +level = "Error" +title = "" + +[[message.snippets]] +source = """ +fn add_title_line(result: &mut Vec, main_annotation: Option<&Annotation>) { + if let Some(annotation) = main_annotation { + result.push(format_title_line( + &annotation.annotation_type, + None, + &annotation.label, + )); + } +} +""" +line_start = 96 +[[message.snippets.annotations]] +label = "Variable defined here" +level = "Error" +range = [100, 110] +[[message.snippets.annotations]] +label = "Referenced here" +level = "Error" +range = [184, 194] +[[message.snippets.annotations]] +label = "Referenced again here" +level = "Error" +range = [243, 253] + +[renderer] +color = true diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/simple.svg b/crates/ruff_annotate_snippets/tests/fixtures/color/simple.svg new file mode 100644 index 0000000000000..7b92d238fd219 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/simple.svg @@ -0,0 +1,43 @@ + + + + + + + error: expected one of `.`, `;`, `?`, or an operator, found `for` + + --> src/format_color.rs:171:9 + + | + + 169 | }) + + | - expected one of `.`, `;`, `?`, or an operator here + + 170 | + + 171 | for line in &self.body { + + | ^^^ unexpected token + + | + + + + diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/simple.toml b/crates/ruff_annotate_snippets/tests/fixtures/color/simple.toml new file mode 100644 index 0000000000000..2e6969f7e7140 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/simple.toml @@ -0,0 +1,22 @@ +[message] +level = "Error" +title = "expected one of `.`, `;`, `?`, or an operator, found `for`" + +[[message.snippets]] +source = """ + }) + + for line in &self.body {""" +line_start = 169 +origin = "src/format_color.rs" +[[message.snippets.annotations]] +label = "unexpected token" +level = "Error" +range = [20, 23] +[[message.snippets.annotations]] +label = "expected one of `.`, `;`, `?`, or an operator here" +level = "Warning" +range = [10, 11] + +[renderer] +color = true diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/strip_line.svg b/crates/ruff_annotate_snippets/tests/fixtures/color/strip_line.svg new file mode 100644 index 0000000000000..9da24fe37bf81 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/strip_line.svg @@ -0,0 +1,36 @@ + + + + + + + error[E0308]: mismatched types + + --> $DIR/whitespace-trimming.rs:4:193 + + | + + LL | ... let _: () = 42; + + | ^^ expected (), found integer + + | + + + + diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/strip_line.toml b/crates/ruff_annotate_snippets/tests/fixtures/color/strip_line.toml new file mode 100644 index 0000000000000..546c96a0384c5 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/strip_line.toml @@ -0,0 +1,18 @@ +[message] +level = "Error" +id = "E0308" +title = "mismatched types" + +[[message.snippets]] +source = " let _: () = 42;" +line_start = 4 +origin = "$DIR/whitespace-trimming.rs" + +[[message.snippets.annotations]] +label = "expected (), found integer" +level = "Error" +range = [192, 194] + +[renderer] +color = true +anonymized_line_numbers = true diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/strip_line_char.svg b/crates/ruff_annotate_snippets/tests/fixtures/color/strip_line_char.svg new file mode 100644 index 0000000000000..cbafc78915cce --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/strip_line_char.svg @@ -0,0 +1,36 @@ + + + + + + + error[E0308]: mismatched types + + --> $DIR/whitespace-trimming.rs:4:193 + + | + + LL | ... let _: () = 42ñ + + | ^^ expected (), found integer + + | + + + + diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/strip_line_char.toml b/crates/ruff_annotate_snippets/tests/fixtures/color/strip_line_char.toml new file mode 100644 index 0000000000000..863abb3fa8550 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/strip_line_char.toml @@ -0,0 +1,18 @@ +[message] +level = "Error" +id = "E0308" +title = "mismatched types" + +[[message.snippets]] +source = " let _: () = 42ñ" +line_start = 4 +origin = "$DIR/whitespace-trimming.rs" + +[[message.snippets.annotations]] +label = "expected (), found integer" +level = "Error" +range = [192, 194] + +[renderer] +color = true +anonymized_line_numbers = true diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/strip_line_non_ws.svg b/crates/ruff_annotate_snippets/tests/fixtures/color/strip_line_non_ws.svg new file mode 100644 index 0000000000000..e4f8a856b649b --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/strip_line_non_ws.svg @@ -0,0 +1,40 @@ + + + + + + + error[E0308]: mismatched types + + --> $DIR/non-whitespace-trimming.rs:4:242 + + | + + LL | ... = (); let _: () = (); let _: () = (); let _: () = 42; let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () ... + + | ^^ ^^ expected `()`, found integer + + | | + + | expected due to this + + | + + + + diff --git a/crates/ruff_annotate_snippets/tests/fixtures/color/strip_line_non_ws.toml b/crates/ruff_annotate_snippets/tests/fixtures/color/strip_line_non_ws.toml new file mode 100644 index 0000000000000..c6573ff40aa37 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/color/strip_line_non_ws.toml @@ -0,0 +1,26 @@ +[message] +level = "Error" +id = "E0308" +title = "mismatched types" + +[[message.snippets]] +source = """ + let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = 42; let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); +""" +line_start = 4 +origin = "$DIR/non-whitespace-trimming.rs" + +[[message.snippets.annotations]] +label = "expected `()`, found integer" +level = "Error" +range = [241, 243] + +[[message.snippets.annotations]] +label = "expected due to this" +level = "Error" +range = [236, 238] + + +[renderer] +anonymized_line_numbers = true +color = true diff --git a/crates/ruff_annotate_snippets/tests/fixtures/deserialize.rs b/crates/ruff_annotate_snippets/tests/fixtures/deserialize.rs new file mode 100644 index 0000000000000..6f27100816635 --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/deserialize.rs @@ -0,0 +1,130 @@ +use serde::Deserialize; +use std::ops::Range; + +use ruff_annotate_snippets::renderer::DEFAULT_TERM_WIDTH; +use ruff_annotate_snippets::{Annotation, Level, Message, Renderer, Snippet}; + +#[derive(Deserialize)] +pub(crate) struct Fixture { + #[serde(default)] + pub(crate) renderer: RendererDef, + pub(crate) message: MessageDef, +} + +#[derive(Deserialize)] +pub struct MessageDef { + #[serde(with = "LevelDef")] + pub level: Level, + pub title: String, + #[serde(default)] + pub id: Option, + #[serde(default)] + pub footer: Vec, + pub snippets: Vec, +} + +impl<'a> From<&'a MessageDef> for Message<'a> { + fn from(val: &'a MessageDef) -> Self { + let MessageDef { + level, + title, + id, + footer, + snippets, + } = val; + let mut message = level.title(title); + if let Some(id) = id { + message = message.id(id); + } + message = message.snippets(snippets.iter().map(Snippet::from)); + message = message.footers(footer.iter().map(Into::into)); + message + } +} + +#[derive(Deserialize)] +pub struct SnippetDef { + pub source: String, + pub line_start: usize, + pub origin: Option, + pub annotations: Vec, + #[serde(default)] + pub fold: bool, +} + +impl<'a> From<&'a SnippetDef> for Snippet<'a> { + fn from(val: &'a SnippetDef) -> Self { + let SnippetDef { + source, + line_start, + origin, + annotations, + fold, + } = val; + let mut snippet = Snippet::source(source).line_start(*line_start).fold(*fold); + if let Some(origin) = origin { + snippet = snippet.origin(origin); + } + snippet = snippet.annotations(annotations.iter().map(Into::into)); + snippet + } +} + +#[derive(Deserialize)] +pub struct AnnotationDef { + pub range: Range, + pub label: String, + #[serde(with = "LevelDef")] + pub level: Level, +} + +impl<'a> From<&'a AnnotationDef> for Annotation<'a> { + fn from(val: &'a AnnotationDef) -> Self { + let AnnotationDef { + range, + label, + level, + } = val; + level.span(range.start..range.end).label(label) + } +} + +#[allow(dead_code)] +#[derive(Deserialize)] +#[serde(remote = "Level")] +enum LevelDef { + Error, + Warning, + Info, + Note, + Help, +} + +#[derive(Default, Deserialize)] +pub struct RendererDef { + #[serde(default)] + anonymized_line_numbers: bool, + #[serde(default)] + term_width: Option, + #[serde(default)] + color: bool, +} + +impl From for Renderer { + fn from(val: RendererDef) -> Self { + let RendererDef { + anonymized_line_numbers, + term_width, + color, + } = val; + + let renderer = if color { + Renderer::styled() + } else { + Renderer::plain() + }; + renderer + .anonymized_line_numbers(anonymized_line_numbers) + .term_width(term_width.unwrap_or(DEFAULT_TERM_WIDTH)) + } +} diff --git a/crates/ruff_annotate_snippets/tests/fixtures/main.rs b/crates/ruff_annotate_snippets/tests/fixtures/main.rs new file mode 100644 index 0000000000000..e54c4e4563cfd --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/fixtures/main.rs @@ -0,0 +1,42 @@ +mod deserialize; + +use crate::deserialize::Fixture; +use ruff_annotate_snippets::{Message, Renderer}; +use snapbox::data::DataFormat; +use snapbox::Data; +use std::error::Error; + +fn main() { + #[cfg(not(windows))] + tryfn::Harness::new("tests/fixtures/", setup, test) + .select(["*/*.toml"]) + .test(); +} + +fn setup(input_path: std::path::PathBuf) -> tryfn::Case { + let parent = input_path + .parent() + .unwrap() + .file_name() + .unwrap() + .to_str() + .unwrap(); + let file_name = input_path.file_name().unwrap().to_str().unwrap(); + let name = format!("{parent}/{file_name}"); + let expected = Data::read_from(&input_path.with_extension("svg"), None); + tryfn::Case { + name, + fixture: input_path, + expected, + } +} + +fn test(input_path: &std::path::Path) -> Result> { + let src = std::fs::read_to_string(input_path)?; + let fixture: Fixture = toml::from_str(&src)?; + let renderer: Renderer = fixture.renderer.into(); + let message: Message<'_> = (&fixture.message).into(); + + let actual = renderer.render(message).to_string(); + Ok(Data::from(actual).coerce_to(DataFormat::TermSvg)) +} diff --git a/crates/ruff_annotate_snippets/tests/formatter.rs b/crates/ruff_annotate_snippets/tests/formatter.rs new file mode 100644 index 0000000000000..2a70a52d5b1de --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/formatter.rs @@ -0,0 +1,963 @@ +// Since this is a vendored copy of `annotate-snippets`, we squash Clippy +// warnings from upstream in order to the reduce the diff. If our copy drifts +// far from upstream such that patches become impractical to apply in both +// places, then we can get rid of these suppressions and fix the lints. +#![allow(clippy::redundant_clone, clippy::should_panic_without_expect)] + +use ruff_annotate_snippets::{Level, Renderer, Snippet}; + +use snapbox::{assert_data_eq, str}; + +#[test] +fn test_i_29() { + let snippets = Level::Error.title("oops").snippet( + Snippet::source("First line\r\nSecond oops line") + .origin("") + .annotation(Level::Error.span(19..23).label("oops")) + .fold(true), + ); + let expected = str![[r#" +error: oops + --> :2:8 + | +2 | Second oops line + | ^^^^ oops + | +"#]]; + + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(snippets).to_string(), expected); +} + +#[test] +fn test_point_to_double_width_characters() { + let snippets = Level::Error.title("").snippet( + Snippet::source("こんにちは、世界") + .origin("") + .annotation(Level::Error.span(18..24).label("world")), + ); + + let expected = str![[r#" +error + --> :1:7 + | +1 | こんにちは、世界 + | ^^^^ world + | +"#]]; + + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(snippets).to_string(), expected); +} + +#[test] +fn test_point_to_double_width_characters_across_lines() { + let snippets = Level::Error.title("").snippet( + Snippet::source("おはよう\nございます") + .origin("") + .annotation(Level::Error.span(6..22).label("Good morning")), + ); + + let expected = str![[r#" +error + --> :1:3 + | +1 | おはよう + | _____^ +2 | | ございます + | |______^ Good morning + | +"#]]; + + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(snippets).to_string(), expected); +} + +#[test] +fn test_point_to_double_width_characters_multiple() { + let snippets = Level::Error.title("").snippet( + Snippet::source("お寿司\n食べたい🍣") + .origin("") + .annotation(Level::Error.span(0..9).label("Sushi1")) + .annotation(Level::Note.span(16..22).label("Sushi2")), + ); + + let expected = str![[r#" +error + --> :1:1 + | +1 | お寿司 + | ^^^^^^ Sushi1 +2 | 食べたい🍣 + | ---- note: Sushi2 + | +"#]]; + + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(snippets).to_string(), expected); +} + +#[test] +fn test_point_to_double_width_characters_mixed() { + let snippets = Level::Error.title("").snippet( + Snippet::source("こんにちは、新しいWorld!") + .origin("") + .annotation(Level::Error.span(18..32).label("New world")), + ); + + let expected = str![[r#" +error + --> :1:7 + | +1 | こんにちは、新しいWorld! + | ^^^^^^^^^^^ New world + | +"#]]; + + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(snippets).to_string(), expected); +} + +#[test] +fn test_format_title() { + let input = Level::Error.title("This is a title").id("E0001"); + + let expected = str![r#"error[E0001]: This is a title"#]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn test_format_snippet_only() { + let source = "This is line 1\nThis is line 2"; + let input = Level::Error + .title("") + .snippet(Snippet::source(source).line_start(5402)); + + let expected = str![[r#" +error + | +5402 | This is line 1 +5403 | This is line 2 + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn test_format_snippets_continuation() { + let src_0 = "This is slice 1"; + let src_1 = "This is slice 2"; + let input = Level::Error + .title("") + .snippet(Snippet::source(src_0).line_start(5402).origin("file1.rs")) + .snippet(Snippet::source(src_1).line_start(2).origin("file2.rs")); + let expected = str![[r#" +error + --> file1.rs + | +5402 | This is slice 1 + | + ::: file2.rs + | + 2 | This is slice 2 + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn test_format_snippet_annotation_standalone() { + let line_1 = "This is line 1"; + let line_2 = "This is line 2"; + let source = [line_1, line_2].join("\n"); + // In line 2 + let range = 22..24; + let input = Level::Error.title("").snippet( + Snippet::source(&source) + .line_start(5402) + .annotation(Level::Info.span(range.clone()).label("Test annotation")), + ); + let expected = str![[r#" +error + | +5402 | This is line 1 +5403 | This is line 2 + | -- info: Test annotation + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn test_format_footer_title() { + let input = Level::Error + .title("") + .footer(Level::Error.title("This __is__ a title")); + let expected = str![[r#" +error + = error: This __is__ a title +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +#[should_panic] +fn test_i26() { + let source = "short"; + let label = "label"; + let input = Level::Error.title("").snippet( + Snippet::source(source) + .line_start(0) + .annotation(Level::Error.span(0..source.len() + 2).label(label)), + ); + let renderer = Renderer::plain(); + let _ = renderer.render(input).to_string(); +} + +#[test] +fn test_source_content() { + let source = "This is an example\nof content lines"; + let input = Level::Error + .title("") + .snippet(Snippet::source(source).line_start(56)); + let expected = str![[r#" +error + | +56 | This is an example +57 | of content lines + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn test_source_annotation_standalone_singleline() { + let source = "tests"; + let input = Level::Error.title("").snippet( + Snippet::source(source) + .line_start(1) + .annotation(Level::Help.span(0..5).label("Example string")), + ); + let expected = str![[r#" +error + | +1 | tests + | ----- help: Example string + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn test_source_annotation_standalone_multiline() { + let source = "tests"; + let input = Level::Error.title("").snippet( + Snippet::source(source) + .line_start(1) + .annotation(Level::Help.span(0..5).label("Example string")) + .annotation(Level::Help.span(0..5).label("Second line")), + ); + let expected = str![[r#" +error + | +1 | tests + | ----- + | | + | help: Example string + | help: Second line + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn test_only_source() { + let input = Level::Error + .title("") + .snippet(Snippet::source("").origin("file.rs")); + let expected = str![[r#" +error +--> file.rs + | + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn test_anon_lines() { + let source = "This is an example\nof content lines\n\nabc"; + let input = Level::Error + .title("") + .snippet(Snippet::source(source).line_start(56)); + let expected = str![[r#" +error + | +LL | This is an example +LL | of content lines +LL | +LL | abc + | +"#]]; + let renderer = Renderer::plain().anonymized_line_numbers(true); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn issue_130() { + let input = Level::Error.title("dummy").snippet( + Snippet::source("foo\nbar\nbaz") + .origin("file/path") + .line_start(3) + .fold(true) + .annotation(Level::Error.span(4..11)), // bar\nbaz + ); + + let expected = str![[r#" +error: dummy + --> file/path:4:1 + | +4 | / bar +5 | | baz + | |___^ + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn unterminated_string_multiline() { + let source = "\ +a\" +// ... +"; + let input = Level::Error.title("").snippet( + Snippet::source(source) + .origin("file/path") + .line_start(3) + .fold(true) + .annotation(Level::Error.span(0..10)), // 1..10 works + ); + let expected = str![[r#" +error + --> file/path:3:1 + | +3 | / a" +4 | | // ... + | |_______^ + | +"#]]; + let renderer = Renderer::plain().anonymized_line_numbers(false); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn char_and_nl_annotate_char() { + let source = "a\r\nb"; + let input = Level::Error.title("").snippet( + Snippet::source(source) + .origin("file/path") + .line_start(3) + .annotation(Level::Error.span(0..2)), // a\r + ); + let expected = str![[r#" +error + --> file/path:3:1 + | +3 | a + | ^ +4 | b + |"#]]; + let renderer = Renderer::plain().anonymized_line_numbers(false); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn char_eol_annotate_char() { + let source = "a\r\nb"; + let input = Level::Error.title("").snippet( + Snippet::source(source) + .origin("file/path") + .line_start(3) + .annotation(Level::Error.span(0..3)), // a\r\n + ); + let expected = str![[r#" +error + --> file/path:3:1 + | +3 | a + | ^ +4 | b + |"#]]; + let renderer = Renderer::plain().anonymized_line_numbers(false); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn char_eol_annotate_char_double_width() { + let snippets = Level::Error.title("").snippet( + Snippet::source("こん\r\nにちは\r\n世界") + .origin("") + .annotation(Level::Error.span(3..8)), // ん\r\n + ); + + let expected = str![[r#" +error + --> :1:2 + | +1 | こん + | ^^ +2 | にちは +3 | 世界 + | +"#]]; + + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(snippets).to_string(), expected); +} + +#[test] +fn annotate_eol() { + let source = "a\r\nb"; + let input = Level::Error.title("").snippet( + Snippet::source(source) + .origin("file/path") + .line_start(3) + .annotation(Level::Error.span(1..2)), // \r + ); + let expected = str![[r#" +error + --> file/path:3:2 + | +3 | a + | ^ +4 | b + |"#]]; + let renderer = Renderer::plain().anonymized_line_numbers(false); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn annotate_eol2() { + let source = "a\r\nb"; + let input = Level::Error.title("").snippet( + Snippet::source(source) + .origin("file/path") + .line_start(3) + .annotation(Level::Error.span(1..3)), // \r\n + ); + let expected = str![[r#" +error + --> file/path:3:2 + | +3 | a + | ^ +4 | b + |"#]]; + let renderer = Renderer::plain().anonymized_line_numbers(false); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn annotate_eol3() { + let source = "a\r\nb"; + let input = Level::Error.title("").snippet( + Snippet::source(source) + .origin("file/path") + .line_start(3) + .annotation(Level::Error.span(2..3)), // \n + ); + let expected = str![[r#" +error + --> file/path:3:2 + | +3 | a + | ^ +4 | b + |"#]]; + let renderer = Renderer::plain().anonymized_line_numbers(false); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn annotate_eol4() { + let source = "a\r\nb"; + let input = Level::Error.title("").snippet( + Snippet::source(source) + .origin("file/path") + .line_start(3) + .annotation(Level::Error.span(2..2)), // \n + ); + let expected = str![[r#" +error + --> file/path:3:2 + | +3 | a + | ^ +4 | b + |"#]]; + let renderer = Renderer::plain().anonymized_line_numbers(false); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn annotate_eol_double_width() { + let snippets = Level::Error.title("").snippet( + Snippet::source("こん\r\nにちは\r\n世界") + .origin("") + .annotation(Level::Error.span(7..8)), // \n + ); + + let expected = str![[r#" +error + --> :1:3 + | +1 | こん + | ^ +2 | にちは +3 | 世界 + | +"#]]; + + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(snippets).to_string(), expected); +} + +#[test] +fn multiline_eol_start() { + let source = "a\r\nb"; + let input = Level::Error.title("").snippet( + Snippet::source(source) + .origin("file/path") + .line_start(3) + .annotation(Level::Error.span(1..4)), // \r\nb + ); + let expected = str![[r#" +error + --> file/path:3:2 + | +3 | a + | __^ +4 | | b + | |_^ + |"#]]; + let renderer = Renderer::plain().anonymized_line_numbers(false); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn multiline_eol_start2() { + let source = "a\r\nb"; + let input = Level::Error.title("").snippet( + Snippet::source(source) + .origin("file/path") + .line_start(3) + .annotation(Level::Error.span(2..4)), // \nb + ); + let expected = str![[r#" +error + --> file/path:3:2 + | +3 | a + | __^ +4 | | b + | |_^ + |"#]]; + let renderer = Renderer::plain().anonymized_line_numbers(false); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn multiline_eol_start3() { + let source = "a\nb"; + let input = Level::Error.title("").snippet( + Snippet::source(source) + .origin("file/path") + .line_start(3) + .annotation(Level::Error.span(1..3)), // \nb + ); + let expected = str![[r#" +error + --> file/path:3:2 + | +3 | a + | __^ +4 | | b + | |_^ + |"#]]; + let renderer = Renderer::plain().anonymized_line_numbers(false); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn multiline_eol_start_double_width() { + let snippets = Level::Error.title("").snippet( + Snippet::source("こん\r\nにちは\r\n世界") + .origin("") + .annotation(Level::Error.span(7..11)), // \r\nに + ); + + let expected = str![[r#" +error + --> :1:3 + | +1 | こん + | _____^ +2 | | にちは + | |__^ +3 | 世界 + | +"#]]; + + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(snippets).to_string(), expected); +} + +#[test] +fn multiline_eol_start_eol_end() { + let source = "a\nb\nc"; + let input = Level::Error.title("").snippet( + Snippet::source(source) + .origin("file/path") + .line_start(3) + .annotation(Level::Error.span(1..4)), // \nb\n + ); + let expected = str![[r#" +error + --> file/path:3:2 + | +3 | a + | __^ +4 | | b + | |__^ +5 | c + | +"#]]; + let renderer = Renderer::plain().anonymized_line_numbers(false); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn multiline_eol_start_eol_end2() { + let source = "a\r\nb\r\nc"; + let input = Level::Error.title("").snippet( + Snippet::source(source) + .origin("file/path") + .line_start(3) + .annotation(Level::Error.span(2..5)), // \nb\r + ); + let expected = str![[r#" +error + --> file/path:3:2 + | +3 | a + | __^ +4 | | b + | |__^ +5 | c + | +"#]]; + let renderer = Renderer::plain().anonymized_line_numbers(false); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn multiline_eol_start_eol_end3() { + let source = "a\r\nb\r\nc"; + let input = Level::Error.title("").snippet( + Snippet::source(source) + .origin("file/path") + .line_start(3) + .annotation(Level::Error.span(2..6)), // \nb\r\n + ); + let expected = str![[r#" +error + --> file/path:3:2 + | +3 | a + | __^ +4 | | b + | |__^ +5 | c + | +"#]]; + let renderer = Renderer::plain().anonymized_line_numbers(false); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn multiline_eol_start_eof_end() { + let source = "a\r\nb"; + let input = Level::Error.title("").snippet( + Snippet::source(source) + .origin("file/path") + .line_start(3) + .annotation(Level::Error.span(1..5)), // \r\nb(EOF) + ); + let expected = str![[r#" +error + --> file/path:3:2 + | +3 | a + | __^ +4 | | b + | |__^ + | +"#]]; + let renderer = Renderer::plain().anonymized_line_numbers(false); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn multiline_eol_start_eof_end_double_width() { + let source = "ん\r\nに"; + let input = Level::Error.title("").snippet( + Snippet::source(source) + .origin("file/path") + .line_start(3) + .annotation(Level::Error.span(3..9)), // \r\nに(EOF) + ); + let expected = str![[r#" +error + --> file/path:3:2 + | +3 | ん + | ___^ +4 | | に + | |___^ + | +"#]]; + let renderer = Renderer::plain().anonymized_line_numbers(false); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn two_single_line_same_line() { + let source = r#"bar = { version = "0.1.0", optional = true }"#; + let input = Level::Error.title("unused optional dependency").snippet( + Snippet::source(source) + .origin("Cargo.toml") + .line_start(4) + .annotation( + Level::Error + .span(0..3) + .label("I need this to be really long so I can test overlaps"), + ) + .annotation( + Level::Info + .span(27..42) + .label("This should also be long but not too long"), + ), + ); + let expected = str![[r#" +error: unused optional dependency + --> Cargo.toml:4:1 + | +4 | bar = { version = "0.1.0", optional = true } + | ^^^ --------------- info: This should also be long but not too long + | | + | I need this to be really long so I can test overlaps + | +"#]]; + let renderer = Renderer::plain().anonymized_line_numbers(false); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn multi_and_single() { + let source = r#"bar = { version = "0.1.0", optional = true } +this is another line +so is this +bar = { version = "0.1.0", optional = true } +"#; + let input = Level::Error.title("unused optional dependency").snippet( + Snippet::source(source) + .line_start(4) + .annotation( + Level::Error + .span(41..119) + .label("I need this to be really long so I can test overlaps"), + ) + .annotation( + Level::Info + .span(27..42) + .label("This should also be long but not too long"), + ), + ); + let expected = str![[r#" +error: unused optional dependency + | +4 | bar = { version = "0.1.0", optional = true } + | ____________________________--------------^ + | | | + | | info: This should also be long but not too long +5 | | this is another line +6 | | so is this +7 | | bar = { version = "0.1.0", optional = true } + | |__________________________________________^ I need this to be really long so I can test overlaps + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn two_multi_and_single() { + let source = r#"bar = { version = "0.1.0", optional = true } +this is another line +so is this +bar = { version = "0.1.0", optional = true } +"#; + let input = Level::Error.title("unused optional dependency").snippet( + Snippet::source(source) + .line_start(4) + .annotation( + Level::Error + .span(41..119) + .label("I need this to be really long so I can test overlaps"), + ) + .annotation( + Level::Error + .span(8..102) + .label("I need this to be really long so I can test overlaps"), + ) + .annotation( + Level::Info + .span(27..42) + .label("This should also be long but not too long"), + ), + ); + let expected = str![[r#" +error: unused optional dependency + | +4 | bar = { version = "0.1.0", optional = true } + | _________^__________________--------------^ + | | | | + | |_________| info: This should also be long but not too long + | || +5 | || this is another line +6 | || so is this +7 | || bar = { version = "0.1.0", optional = true } + | ||_________________________^________________^ I need this to be really long so I can test overlaps + | |__________________________| + | I need this to be really long so I can test overlaps + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn three_multi_and_single() { + let source = r#"bar = { version = "0.1.0", optional = true } +this is another line +so is this +bar = { version = "0.1.0", optional = true } +this is another line +"#; + let input = Level::Error.title("unused optional dependency").snippet( + Snippet::source(source) + .line_start(4) + .annotation( + Level::Error + .span(41..119) + .label("I need this to be really long so I can test overlaps"), + ) + .annotation( + Level::Error + .span(8..102) + .label("I need this to be really long so I can test overlaps"), + ) + .annotation( + Level::Error + .span(48..126) + .label("I need this to be really long so I can test overlaps"), + ) + .annotation( + Level::Info + .span(27..42) + .label("This should also be long but not too long"), + ), + ); + let expected = str![[r#" +error: unused optional dependency + | +4 | bar = { version = "0.1.0", optional = true } + | __________^__________________--------------^ + | | | | + | |__________| info: This should also be long but not too long + | || +5 | || this is another line + | || ____^ +6 | ||| so is this +7 | ||| bar = { version = "0.1.0", optional = true } + | |||_________________________^________________^ I need this to be really long so I can test overlaps + | |_|_________________________| + | | I need this to be really long so I can test overlaps +8 | | this is another line + | |____^ I need this to be really long so I can test overlaps + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn origin_correct_start_line() { + let source = "aaa\nbbb\nccc\nddd\n"; + let input = Level::Error.title("title").snippet( + Snippet::source(source) + .origin("origin.txt") + .fold(false) + .annotation(Level::Error.span(8..8 + 3).label("annotation")), + ); + + let expected = str![[r#" +error: title + --> origin.txt:3:1 + | +1 | aaa +2 | bbb +3 | ccc + | ^^^ annotation +4 | ddd + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn origin_correct_mid_line() { + let source = "aaa\nbbb\nccc\nddd\n"; + let input = Level::Error.title("title").snippet( + Snippet::source(source) + .origin("origin.txt") + .fold(false) + .annotation(Level::Error.span(8 + 1..8 + 3).label("annotation")), + ); + + let expected = str![[r#" +error: title + --> origin.txt:3:2 + | +1 | aaa +2 | bbb +3 | ccc + | ^^ annotation +4 | ddd + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} diff --git a/crates/ruff_annotate_snippets/tests/rustc_tests.rs b/crates/ruff_annotate_snippets/tests/rustc_tests.rs new file mode 100644 index 0000000000000..f89c6a4c5df6d --- /dev/null +++ b/crates/ruff_annotate_snippets/tests/rustc_tests.rs @@ -0,0 +1,783 @@ +//! These tests have been adapted from [Rust's parser tests][parser-tests]. +//! +//! [parser-tests]: https://github.com/rust-lang/rust/blob/894f7a4ba6554d3797404bbf550d9919df060b97/compiler/rustc_parse/src/parser/tests.rs + +use ruff_annotate_snippets::{Level, Renderer, Snippet}; + +use snapbox::{assert_data_eq, str}; + +#[test] +fn ends_on_col0() { + let source = r#" +fn foo() { +} +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(10..13).label("test")), + ); + + let expected = str![[r#" +error: foo + --> test.rs:2:10 + | +2 | fn foo() { + | __________^ +3 | | } + | |_^ test + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} +#[test] +fn ends_on_col2() { + let source = r#" +fn foo() { + + + } +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(10..17).label("test")), + ); + + let expected = str![[r#" +error: foo + --> test.rs:2:10 + | +2 | fn foo() { + | __________^ +3 | | +4 | | +5 | | } + | |___^ test + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} +#[test] +fn non_nested() { + let source = r#" +fn foo() { + X0 Y0 + X1 Y1 + X2 Y2 +} +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(14..32).label("`X` is a good letter")) + .annotation( + Level::Warning + .span(17..35) + .label("`Y` is a good letter too"), + ), + ); + + let expected = str![[r#" +error: foo + --> test.rs:3:3 + | +3 | X0 Y0 + | ____^ - + | | ______| +4 | || X1 Y1 +5 | || X2 Y2 + | ||____^__- `Y` is a good letter too + | |_____| + | `X` is a good letter + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} +#[test] +fn nested() { + let source = r#" +fn foo() { + X0 Y0 + Y1 X1 +} +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(14..27).label("`X` is a good letter")) + .annotation( + Level::Warning + .span(17..24) + .label("`Y` is a good letter too"), + ), + ); + + let expected = str![[r#" +error: foo + --> test.rs:3:3 + | +3 | X0 Y0 + | ____^ - + | | ______| +4 | || Y1 X1 + | ||____-__^ `X` is a good letter + | |____| + | `Y` is a good letter too + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} +#[test] +fn different_overlap() { + let source = r#" +fn foo() { + X0 Y0 Z0 + X1 Y1 Z1 + X2 Y2 Z2 + X3 Y3 Z3 +} +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(17..38).label("`X` is a good letter")) + .annotation( + Level::Warning + .span(31..49) + .label("`Y` is a good letter too"), + ), + ); + + let expected = str![[r#" +error: foo + --> test.rs:3:6 + | +3 | X0 Y0 Z0 + | _______^ +4 | | X1 Y1 Z1 + | | _________- +5 | || X2 Y2 Z2 + | ||____^ `X` is a good letter +6 | | X3 Y3 Z3 + | |____- `Y` is a good letter too + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} +#[test] +fn triple_overlap() { + let source = r#" +fn foo() { + X0 Y0 Z0 + X1 Y1 Z1 + X2 Y2 Z2 +} +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(14..38).label("`X` is a good letter")) + .annotation( + Level::Warning + .span(17..41) + .label("`Y` is a good letter too"), + ) + .annotation(Level::Warning.span(20..44).label("`Z` label")), + ); + + let expected = str![[r#" +error: foo + --> test.rs:3:3 + | +3 | X0 Y0 Z0 + | _____^ - - + | | _______| | + | || _________| +4 | ||| X1 Y1 Z1 +5 | ||| X2 Y2 Z2 + | |||____^__-__- `Z` label + | ||_____|__| + | |______| `Y` is a good letter too + | `X` is a good letter + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} +#[test] +fn triple_exact_overlap() { + let source = r#" +fn foo() { + X0 Y0 Z0 + X1 Y1 Z1 + X2 Y2 Z2 +} +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(14..38).label("`X` is a good letter")) + .annotation( + Level::Warning + .span(14..38) + .label("`Y` is a good letter too"), + ) + .annotation(Level::Warning.span(14..38).label("`Z` label")), + ); + + // This should have a `^` but we currently don't support the idea of a + // "primary" annotation, which would solve this + let expected = str![[r#" +error: foo + --> test.rs:3:3 + | +3 | / X0 Y0 Z0 +4 | | X1 Y1 Z1 +5 | | X2 Y2 Z2 + | | - + | |____| + | `X` is a good letter + | `Y` is a good letter too + | `Z` label + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} +#[test] +fn minimum_depth() { + let source = r#" +fn foo() { + X0 Y0 Z0 + X1 Y1 Z1 + X2 Y2 Z2 + X3 Y3 Z3 +} +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(17..27).label("`X` is a good letter")) + .annotation( + Level::Warning + .span(28..44) + .label("`Y` is a good letter too"), + ) + .annotation(Level::Warning.span(36..52).label("`Z`")), + ); + + let expected = str![[r#" +error: foo + --> test.rs:3:6 + | +3 | X0 Y0 Z0 + | _______^ +4 | | X1 Y1 Z1 + | | ____^_- + | ||____| + | | `X` is a good letter +5 | | X2 Y2 Z2 + | |___-______- `Y` is a good letter too + | ___| + | | +6 | | X3 Y3 Z3 + | |_______- `Z` + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} +#[test] +fn non_overlapping() { + let source = r#" +fn foo() { + X0 Y0 Z0 + X1 Y1 Z1 + X2 Y2 Z2 + X3 Y3 Z3 +} +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(14..27).label("`X` is a good letter")) + .annotation( + Level::Warning + .span(39..55) + .label("`Y` is a good letter too"), + ), + ); + + let expected = str![[r#" +error: foo + --> test.rs:3:3 + | +3 | / X0 Y0 Z0 +4 | | X1 Y1 Z1 + | |____^ `X` is a good letter +5 | X2 Y2 Z2 + | ______- +6 | | X3 Y3 Z3 + | |__________- `Y` is a good letter too + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} +#[test] +fn overlapping_start_and_end() { + let source = r#" +fn foo() { + X0 Y0 Z0 + X1 Y1 Z1 + X2 Y2 Z2 + X3 Y3 Z3 +} +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(17..27).label("`X` is a good letter")) + .annotation( + Level::Warning + .span(31..55) + .label("`Y` is a good letter too"), + ), + ); + + let expected = str![[r#" +error: foo + --> test.rs:3:6 + | +3 | X0 Y0 Z0 + | _______^ +4 | | X1 Y1 Z1 + | | ____^____- + | ||____| + | | `X` is a good letter +5 | | X2 Y2 Z2 +6 | | X3 Y3 Z3 + | |__________- `Y` is a good letter too + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} +#[test] +fn multiple_labels_primary_without_message() { + let source = r#" +fn foo() { + a { b { c } d } +} +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(18..25).label("")) + .annotation(Level::Warning.span(14..27).label("`a` is a good letter")) + .annotation(Level::Warning.span(22..23).label("")), + ); + + let expected = str![[r#" +error: foo + --> test.rs:3:7 + | +3 | a { b { c } d } + | ----^^^^-^^-- `a` is a good letter + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} +#[test] +fn multiple_labels_secondary_without_message() { + let source = r#" +fn foo() { + a { b { c } d } +} +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(14..27).label("`a` is a good letter")) + .annotation(Level::Warning.span(18..25).label("")), + ); + + let expected = str![[r#" +error: foo + --> test.rs:3:3 + | +3 | a { b { c } d } + | ^^^^-------^^ `a` is a good letter + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} +#[test] +fn multiple_labels_primary_without_message_2() { + let source = r#" +fn foo() { + a { b { c } d } +} +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(18..25).label("`b` is a good letter")) + .annotation(Level::Warning.span(14..27).label("")) + .annotation(Level::Warning.span(22..23).label("")), + ); + + let expected = str![[r#" +error: foo + --> test.rs:3:7 + | +3 | a { b { c } d } + | ----^^^^-^^-- + | | + | `b` is a good letter + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} +#[test] +fn multiple_labels_secondary_without_message_2() { + let source = r#" +fn foo() { + a { b { c } d } +} +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(14..27).label("")) + .annotation(Level::Warning.span(18..25).label("`b` is a good letter")), + ); + + let expected = str![[r#" +error: foo + --> test.rs:3:3 + | +3 | a { b { c } d } + | ^^^^-------^^ + | | + | `b` is a good letter + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} +#[test] +fn multiple_labels_secondary_without_message_3() { + let source = r#" +fn foo() { + a bc d +} +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(14..18).label("`a` is a good letter")) + .annotation(Level::Warning.span(18..22).label("")), + ); + + let expected = str![[r#" +error: foo + --> test.rs:3:3 + | +3 | a bc d + | ^^^^---- + | | + | `a` is a good letter + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} +#[test] +fn multiple_labels_without_message() { + let source = r#" +fn foo() { + a { b { c } d } +} +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(14..27).label("")) + .annotation(Level::Warning.span(18..25).label("")), + ); + + let expected = str![[r#" +error: foo + --> test.rs:3:3 + | +3 | a { b { c } d } + | ^^^^-------^^ + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} +#[test] +fn multiple_labels_without_message_2() { + let source = r#" +fn foo() { + a { b { c } d } +} +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(18..25).label("")) + .annotation(Level::Warning.span(14..27).label("")) + .annotation(Level::Warning.span(22..23).label("")), + ); + + let expected = str![[r#" +error: foo + --> test.rs:3:7 + | +3 | a { b { c } d } + | ----^^^^-^^-- + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} +#[test] +fn multiple_labels_with_message() { + let source = r#" +fn foo() { + a { b { c } d } +} +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(14..27).label("`a` is a good letter")) + .annotation(Level::Warning.span(18..25).label("`b` is a good letter")), + ); + + let expected = str![[r#" +error: foo + --> test.rs:3:3 + | +3 | a { b { c } d } + | ^^^^-------^^ + | | | + | | `b` is a good letter + | `a` is a good letter + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} +#[test] +fn ingle_label_with_message() { + let source = r#" +fn foo() { + a { b { c } d } +} +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(14..27).label("`a` is a good letter")), + ); + + let expected = str![[r#" +error: foo + --> test.rs:3:3 + | +3 | a { b { c } d } + | ^^^^^^^^^^^^^ `a` is a good letter + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} +#[test] +fn single_label_without_message() { + let source = r#" +fn foo() { + a { b { c } d } +} +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(14..27).label("")), + ); + + let expected = str![[r#" +error: foo + --> test.rs:3:3 + | +3 | a { b { c } d } + | ^^^^^^^^^^^^^ + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} +#[test] +fn long_snippet() { + let source = r#" +fn foo() { + X0 Y0 Z0 + X1 Y1 Z1 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 + X2 Y2 Z2 + X3 Y3 Z3 +} +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(17..27).label("`X` is a good letter")) + .annotation( + Level::Warning + .span(31..76) + .label("`Y` is a good letter too"), + ), + ); + + let expected = str![[r#" +error: foo + --> test.rs:3:6 + | + 3 | X0 Y0 Z0 + | _______^ + 4 | | X1 Y1 Z1 + | | ____^____- + | ||____| + | | `X` is a good letter + 5 | | 1 +... | +15 | | X2 Y2 Z2 +16 | | X3 Y3 Z3 + | |__________- `Y` is a good letter too + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} +#[test] +fn long_snippet_multiple_spans() { + let source = r#" +fn foo() { + X0 Y0 Z0 +1 +2 +3 + X1 Y1 Z1 +4 +5 +6 + X2 Y2 Z2 +7 +8 +9 +10 + X3 Y3 Z3 +} +"#; + let input = Level::Error.title("foo").snippet( + Snippet::source(source) + .line_start(1) + .origin("test.rs") + .fold(true) + .annotation(Level::Error.span(17..73).label("`Y` is a good letter")) + .annotation( + Level::Warning + .span(37..56) + .label("`Z` is a good letter too"), + ), + ); + + let expected = str![[r#" +error: foo + --> test.rs:3:6 + | + 3 | X0 Y0 Z0 + | _______^ + 4 | | 1 + 5 | | 2 + 6 | | 3 + 7 | | X1 Y1 Z1 + | | _________- + 8 | || 4 + 9 | || 5 +10 | || 6 +11 | || X2 Y2 Z2 + | ||__________- `Z` is a good letter too +12 | | 7 +... | +15 | | 10 +16 | | X3 Y3 Z3 + | |________^ `Y` is a good letter + | +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input).to_string(), expected); +} From 90ef6e1d7b903a2ae4f8d0751fc6a9e793ed0fd5 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Fri, 20 Dec 2024 13:01:51 -0500 Subject: [PATCH 02/18] ruff_annotate_snippets: make small change to enable omitting header This is a tiny change that, perhaps slightly shady, permits us to use the `annotate-snippets` renderer without its mandatory header (which wasn't there in `annotate-snippets 0.9`). Specifically, we can now do this: Level::None.title("") The combination of a "none" level and an empty label results in the `annotate-snippets` header being skipped entirely. (Not even an empty line is written.) This is maybe not the right API for upstream `annotate-snippets`, but it's very easy for us to do and unblocks the upgrade (albeit relying on a vendored copy). Ref https://github.com/rust-lang/annotate-snippets-rs/issues/167 --- .../src/renderer/display_list.rs | 1 + crates/ruff_annotate_snippets/src/snippet.rs | 2 ++ .../ruff_annotate_snippets/tests/formatter.rs | 29 +++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/crates/ruff_annotate_snippets/src/renderer/display_list.rs b/crates/ruff_annotate_snippets/src/renderer/display_list.rs index b2e27d4afec34..95a1d69b1c110 100644 --- a/crates/ruff_annotate_snippets/src/renderer/display_list.rs +++ b/crates/ruff_annotate_snippets/src/renderer/display_list.rs @@ -909,6 +909,7 @@ pub(crate) enum DisplayAnnotationType { impl From for DisplayAnnotationType { fn from(at: snippet::Level) -> Self { match at { + snippet::Level::None => DisplayAnnotationType::None, snippet::Level::Error => DisplayAnnotationType::Error, snippet::Level::Warning => DisplayAnnotationType::Warning, snippet::Level::Info => DisplayAnnotationType::Info, diff --git a/crates/ruff_annotate_snippets/src/snippet.rs b/crates/ruff_annotate_snippets/src/snippet.rs index 9a1394604b859..5830a7b5cd068 100644 --- a/crates/ruff_annotate_snippets/src/snippet.rs +++ b/crates/ruff_annotate_snippets/src/snippet.rs @@ -126,6 +126,8 @@ impl<'a> Annotation<'a> { /// Types of annotations. #[derive(Debug, Clone, Copy, PartialEq)] pub enum Level { + /// Do not attach any annotation. + None, /// Error annotations are displayed using red color and "^" character. Error, /// Warning annotations are displayed using blue color and "-" character. diff --git a/crates/ruff_annotate_snippets/tests/formatter.rs b/crates/ruff_annotate_snippets/tests/formatter.rs index 2a70a52d5b1de..e66ad115475fb 100644 --- a/crates/ruff_annotate_snippets/tests/formatter.rs +++ b/crates/ruff_annotate_snippets/tests/formatter.rs @@ -127,6 +127,35 @@ fn test_format_title() { assert_data_eq!(renderer.render(input).to_string(), expected); } +/// Tests that we can format a message *without* a header. +/// +/// This uses `Level::None`, which is somewhat of a hacky API addition I made +/// to our vendored copy of `annotate-snippets` in order to do exactly what +/// this test asserts: skip the header. +#[test] +fn test_format_skip_title() { + let source = + "# Docstring followed by a newline\n\ndef foobar(foot, bar={}):\n \"\"\"\n \"\"\"\n"; + let src_annotation = Level::Error.span(56..58).label("B006"); + let snippet = Snippet::source(source) + .line_start(1) + .annotation(src_annotation) + .fold(false); + let message = Level::None.title("").snippet(snippet); + + let expected = str![[r#" + | +1 | # Docstring followed by a newline +2 | +3 | def foobar(foot, bar={}): + | ^^ B006 +4 | """ +5 | """ + | +"#]]; + assert_data_eq!(Renderer::plain().render(message).to_string(), expected); +} + #[test] fn test_format_snippet_only() { let source = "This is line 1\nThis is line 2"; From 8a8ba10b2591992ccf8164a0ef7465eaf6b1a248 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Fri, 20 Dec 2024 14:19:32 -0500 Subject: [PATCH 03/18] ruff_linter,ruff_python_parser: migrate to updated `annotate-snippets` This is pretty much just moving to the new API and taking care to use byte offsets. This is *almost* enough. The next commit will fix a bug involving the handling of unprintable characters as a result of switching to byte offsets. --- Cargo.lock | 25 +------ Cargo.toml | 1 - crates/ruff_linter/Cargo.toml | 2 +- crates/ruff_linter/src/message/text.rs | 73 ++++++++------------- crates/ruff_python_parser/Cargo.toml | 2 +- crates/ruff_python_parser/tests/fixtures.rs | 39 ++++------- 6 files changed, 43 insertions(+), 99 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2a28d178fa101..67976dbefeded 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -57,16 +57,6 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7021ce4924a3f25f802b2cccd1af585e39ea1a363a1aa2e72afe54b67a3a7a7" -[[package]] -name = "annotate-snippets" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccaf7e9dfbb6ab22c82e473cd1a8a7bd313c19a5b7e40970f3d89ef5a5c9e81e" -dependencies = [ - "unicode-width 0.1.13", - "yansi-term", -] - [[package]] name = "anstream" version = "0.6.18" @@ -326,7 +316,7 @@ version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5b5db619f3556839cb2223ae86ff3f9a09da2c5013be42bc9af08c9589bf70c" dependencies = [ - "annotate-snippets 0.6.1", + "annotate-snippets", ] [[package]] @@ -2828,7 +2818,6 @@ name = "ruff_linter" version = "0.9.0" dependencies = [ "aho-corasick", - "annotate-snippets 0.9.2", "anyhow", "bitflags 2.6.0", "chrono", @@ -2852,6 +2841,7 @@ dependencies = [ "pyproject-toml", "quick-junit", "regex", + "ruff_annotate_snippets", "ruff_cache", "ruff_diagnostics", "ruff_index", @@ -3011,13 +3001,13 @@ dependencies = [ name = "ruff_python_parser" version = "0.0.0" dependencies = [ - "annotate-snippets 0.9.2", "anyhow", "bitflags 2.6.0", "bstr", "compact_str", "insta", "memchr", + "ruff_annotate_snippets", "ruff_python_ast", "ruff_python_trivia", "ruff_source_file", @@ -4642,15 +4632,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" -[[package]] -name = "yansi-term" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe5c30ade05e61656247b2e334a031dfd0cc466fadef865bdcdea8d537951bf1" -dependencies = [ - "winapi", -] - [[package]] name = "yoke" version = "0.7.4" diff --git a/Cargo.toml b/Cargo.toml index 121baf422cbe3..6f3264611c170 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,7 +44,6 @@ red_knot_test = { path = "crates/red_knot_test" } red_knot_workspace = { path = "crates/red_knot_workspace", default-features = false } aho-corasick = { version = "1.1.3" } -annotate-snippets = { version = "0.9.2", features = ["color"] } anstream = { version = "0.6.18" } anstyle = { version = "1.0.10" } anyhow = { version = "1.0.80" } diff --git a/crates/ruff_linter/Cargo.toml b/crates/ruff_linter/Cargo.toml index 9a7236ed32257..1595c528ca267 100644 --- a/crates/ruff_linter/Cargo.toml +++ b/crates/ruff_linter/Cargo.toml @@ -13,6 +13,7 @@ license = { workspace = true } [lib] [dependencies] +ruff_annotate_snippets = { workspace = true } ruff_cache = { workspace = true } ruff_diagnostics = { workspace = true, features = ["serde"] } ruff_index = { workspace = true } @@ -30,7 +31,6 @@ ruff_source_file = { workspace = true, features = ["serde"] } ruff_text_size = { workspace = true } aho-corasick = { workspace = true } -annotate-snippets = { workspace = true, features = ["color"] } anyhow = { workspace = true } bitflags = { workspace = true } chrono = { workspace = true } diff --git a/crates/ruff_linter/src/message/text.rs b/crates/ruff_linter/src/message/text.rs index 7b3c417e48e10..98c7dddc36416 100644 --- a/crates/ruff_linter/src/message/text.rs +++ b/crates/ruff_linter/src/message/text.rs @@ -2,10 +2,9 @@ use std::borrow::Cow; use std::fmt::{Display, Formatter}; use std::io::Write; -use annotate_snippets::display_list::{DisplayList, FormatOptions}; -use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation}; use bitflags::bitflags; use colored::Colorize; +use ruff_annotate_snippets::{Level, Renderer, Snippet}; use ruff_notebook::NotebookIndex; use ruff_source_file::{OneIndexed, SourceLocation}; @@ -186,12 +185,8 @@ pub(super) struct MessageCodeFrame<'a> { impl Display for MessageCodeFrame<'_> { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { let suggestion = self.message.suggestion(); - let footer = if suggestion.is_some() { - vec![Annotation { - id: None, - label: suggestion, - annotation_type: AnnotationType::Help, - }] + let footers = if let Some(suggestion) = suggestion { + vec![Level::Help.title(suggestion)] } else { Vec::new() }; @@ -257,51 +252,37 @@ impl Display for MessageCodeFrame<'_> { let source_text = source.text.show_nonprinting(); - let start_char = source.text[TextRange::up_to(source.annotation_range.start())] - .chars() - .count(); - - let char_length = source.text[source.annotation_range].chars().count(); - let label = self .message .rule() .map_or_else(String::new, |rule| rule.noqa_code().to_string()); - let snippet = Snippet { - title: None, - slices: vec![Slice { - source: &source_text, - line_start: self.notebook_index.map_or_else( - || start_index.get(), - |notebook_index| { - notebook_index - .cell_row(start_index) - .unwrap_or(OneIndexed::MIN) - .get() - }, - ), - annotations: vec![SourceAnnotation { - label: &label, - annotation_type: AnnotationType::Error, - range: (start_char, start_char + char_length), - }], - // The origin (file name, line number, and column number) is already encoded - // in the `label`. - origin: None, - fold: false, - }], - footer, - opt: FormatOptions { - #[cfg(test)] - color: false, - #[cfg(not(test))] - color: colored::control::SHOULD_COLORIZE.should_colorize(), - ..FormatOptions::default() + let line_start = self.notebook_index.map_or_else( + || start_index.get(), + |notebook_index| { + notebook_index + .cell_row(start_index) + .unwrap_or(OneIndexed::MIN) + .get() }, - }; + ); - writeln!(f, "{message}", message = DisplayList::from(snippet)) + let span = usize::from(source.annotation_range.start()) + ..usize::from(source.annotation_range.end()); + let annotation = Level::Error.span(span).label(&label); + let snippet = Snippet::source(&source_text) + .line_start(line_start) + .annotation(annotation) + .fold(false); + let message = Level::None.title("").snippet(snippet).footers(footers); + + let renderer = if !cfg!(test) && colored::control::SHOULD_COLORIZE.should_colorize() { + Renderer::styled() + } else { + Renderer::plain() + }; + let rendered = renderer.render(message); + writeln!(f, "{rendered}") } } diff --git a/crates/ruff_python_parser/Cargo.toml b/crates/ruff_python_parser/Cargo.toml index a74a93143e28d..d6b8425bc35f1 100644 --- a/crates/ruff_python_parser/Cargo.toml +++ b/crates/ruff_python_parser/Cargo.toml @@ -28,9 +28,9 @@ unicode_names2 = { workspace = true } unicode-normalization = { workspace = true } [dev-dependencies] +ruff_annotate_snippets = { workspace = true } ruff_source_file = { workspace = true } -annotate-snippets = { workspace = true } anyhow = { workspace = true } insta = { workspace = true, features = ["glob"] } walkdir = { workspace = true } diff --git a/crates/ruff_python_parser/tests/fixtures.rs b/crates/ruff_python_parser/tests/fixtures.rs index 893695fa94f5b..e8516b6a648f9 100644 --- a/crates/ruff_python_parser/tests/fixtures.rs +++ b/crates/ruff_python_parser/tests/fixtures.rs @@ -3,9 +3,7 @@ use std::fmt::{Formatter, Write}; use std::fs; use std::path::Path; -use annotate_snippets::display_list::{DisplayList, FormatOptions}; -use annotate_snippets::snippet::{AnnotationType, Slice, Snippet, SourceAnnotation}; - +use ruff_annotate_snippets::{Level, Renderer, Snippet}; use ruff_python_ast::visitor::source_order::{walk_module, SourceOrderVisitor, TraversalSignal}; use ruff_python_ast::{AnyNodeRef, Mod}; use ruff_python_parser::{parse_unchecked, Mode, ParseErrorType, Token}; @@ -203,33 +201,18 @@ impl std::fmt::Display for CodeFrame<'_> { .source_code .slice(TextRange::new(start_offset, end_offset)); - let start_char = source[TextRange::up_to(annotation_range.start())] - .chars() - .count(); - - let char_length = source[annotation_range].chars().count(); let label = format!("Syntax Error: {error}", error = self.error); - let snippet = Snippet { - title: None, - slices: vec![Slice { - source, - line_start: start_index.get(), - annotations: vec![SourceAnnotation { - label: &label, - annotation_type: AnnotationType::Error, - range: (start_char, start_char + char_length), - }], - // The origin (file name, line number, and column number) is already encoded - // in the `label`. - origin: None, - fold: false, - }], - footer: Vec::new(), - opt: FormatOptions::default(), - }; - - writeln!(f, "{message}", message = DisplayList::from(snippet)) + let span = usize::from(annotation_range.start())..usize::from(annotation_range.end()); + let annotation = Level::Error.span(span).label(&label); + let snippet = Snippet::source(source) + .line_start(start_index.get()) + .annotation(annotation) + .fold(false); + let message = Level::None.title("").snippet(snippet); + let renderer = Renderer::plain(); + let rendered = renderer.render(message); + writeln!(f, "{rendered}") } } From 725d17ab254d23e8aa4b379244d3d53a0bd91341 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Wed, 8 Jan 2025 15:07:33 -0500 Subject: [PATCH 04/18] ruff_linter: fix handling of unprintable characters Previously, we were replacing unprintable ASCII characters with a printable representation of them via fancier Unicode characters. Since `annotate-snippets` used to use codepoint offsets, this didn't make our ranges incorrect: we swapped one codepoint for another. But now, with the `annotate-snippets` upgrade, we use byte offsets (which is IMO the correct choice). However, this means our ranges can be thrown off since an ASCII codepoint is always one byte and a non-ASCII codepoint is always more than one byte. Instead of tweaking the `ShowNonprinting` trait and making it more complicated (which is used in places other than this diagnostic rendering it seems), we instead change `replace_whitespace` to handle non-printable characters. This works out because `replace_whitespace` was already updating the annotation range to account for the tab replacement. We copy that approach for unprintable characters. --- crates/ruff_linter/src/message/text.rs | 65 ++++++++++++++++++-------- 1 file changed, 46 insertions(+), 19 deletions(-) diff --git a/crates/ruff_linter/src/message/text.rs b/crates/ruff_linter/src/message/text.rs index 98c7dddc36416..24e0787aa35ba 100644 --- a/crates/ruff_linter/src/message/text.rs +++ b/crates/ruff_linter/src/message/text.rs @@ -15,7 +15,6 @@ use crate::line_width::{IndentWidth, LineWidthBuilder}; use crate::message::diff::Diff; use crate::message::{Emitter, EmitterContext, Message}; use crate::settings::types::UnsafeFixes; -use crate::text_helpers::ShowNonprinting; bitflags! { #[derive(Default)] @@ -245,13 +244,11 @@ impl Display for MessageCodeFrame<'_> { let start_offset = source_code.line_start(start_index); let end_offset = source_code.line_end(end_index); - let source = replace_whitespace( + let source = replace_whitespace_and_unprintable( source_code.slice(TextRange::new(start_offset, end_offset)), self.message.range() - start_offset, ); - let source_text = source.text.show_nonprinting(); - let label = self .message .rule() @@ -270,7 +267,7 @@ impl Display for MessageCodeFrame<'_> { let span = usize::from(source.annotation_range.start()) ..usize::from(source.annotation_range.end()); let annotation = Level::Error.span(span).label(&label); - let snippet = Snippet::source(&source_text) + let snippet = Snippet::source(&source.text) .line_start(line_start) .annotation(annotation) .fold(false); @@ -286,38 +283,68 @@ impl Display for MessageCodeFrame<'_> { } } -fn replace_whitespace(source: &str, annotation_range: TextRange) -> SourceCode { +/// Given some source code and an annotation range, this routine replaces +/// tabs with ASCII whitespace, and unprintable characters with printable +/// representations of them. +/// +/// The source code returned has an annotation that is updated to reflect +/// changes made to the source code (if any). +fn replace_whitespace_and_unprintable(source: &str, annotation_range: TextRange) -> SourceCode { let mut result = String::new(); let mut last_end = 0; let mut range = annotation_range; let mut line_width = LineWidthBuilder::new(IndentWidth::default()); + // Updates the range given by the caller whenever a single byte (at + // `index` in `source`) is replaced with `len` bytes. + // + // When the index occurs before the start of the range, the range is + // offset by `len`. When the range occurs after or at the start but before + // the end, then the end of the range only is offset by `len`. + let mut update_range = |index, len| { + if index < usize::from(annotation_range.start()) { + range += TextSize::new(len - 1); + } else if index < usize::from(annotation_range.end()) { + range = range.add_end(TextSize::new(len - 1)); + } + }; + + // If `c` is an unprintable character, then this returns a printable + // representation of it (using a fancier Unicode codepoint). + let unprintable_replacement = |c: char| -> Option { + match c { + '\x07' => Some('␇'), + '\x08' => Some('␈'), + '\x1b' => Some('␛'), + '\x7f' => Some('␡'), + _ => None, + } + }; + for (index, c) in source.char_indices() { let old_width = line_width.get(); line_width = line_width.add_char(c); if matches!(c, '\t') { - // SAFETY: The difference is a value in the range [1..TAB_SIZE] which is guaranteed to be less than `u32`. - #[allow(clippy::cast_possible_truncation)] - let tab_width = (line_width.get() - old_width) as u32; - - if index < usize::from(annotation_range.start()) { - range += TextSize::new(tab_width - 1); - } else if index < usize::from(annotation_range.end()) { - range = range.add_end(TextSize::new(tab_width - 1)); - } - + let tab_width = u32::try_from(line_width.get() - old_width) + .expect("small width because of tab size"); result.push_str(&source[last_end..index]); - for _ in 0..tab_width { result.push(' '); } - last_end = index + 1; + update_range(index, tab_width); + } else if let Some(printable) = unprintable_replacement(c) { + result.push_str(&source[last_end..index]); + result.push(printable); + last_end = index + 1; + + let len = u32::try_from(printable.len_utf8()).expect("4 or fewer UTF-8 code units"); + update_range(index, len); } } - // No tabs + // No tabs or unprintable chars if result.is_empty() { SourceCode { annotation_range, From c738488a5fc62685d488c115e8d62d03ae272ce5 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Tue, 7 Jan 2025 10:45:21 -0500 Subject: [PATCH 05/18] test: update snapshots with just whitespace changes These snapshot changes should *all* only be a result of changes to trailing whitespace in the output. I checked a psuedo random sample of these, and the whitespace found in the previous snapshots seems to be an artifact of the rendering and _not_ of the source data. So this seems like a strict bug fix to me. There are other snapshots with whitespace changes, but they also have other changes that we split out into separate commits. Basically, we're going to do approximately one commit per category of change. This represents, by far, the biggest chunk of changes to snapshots as a result of the `annotate-snippets` upgrade. --- crates/ruff/tests/integration_test.rs | 6 +- ...message__text__tests__notebook_output.snap | 3 +- ...__message__text__tests__syntax_errors.snap | 5 +- ...les__airflow__tests__AIR001_AIR001.py.snap | 6 +- ...les__airflow__tests__AIR301_AIR301.py.snap | 4 +- ...airflow__tests__AIR302_AIR302_args.py.snap | 10 +- ...sts__AIR302_AIR302_class_attribute.py.snap | 19 ++- ...irflow__tests__AIR302_AIR302_names.py.snap | 127 ++++++++-------- ...les__airflow__tests__AIR303_AIR303.py.snap | 47 +++--- ...s__eradicate__tests__ERA001_ERA001.py.snap | 7 +- ..._flake8_2020__tests__YTT101_YTT101.py.snap | 5 +- ..._flake8_2020__tests__YTT102_YTT102.py.snap | 3 +- ..._flake8_2020__tests__YTT103_YTT103.py.snap | 3 +- ..._flake8_2020__tests__YTT201_YTT201.py.snap | 3 +- ..._flake8_2020__tests__YTT202_YTT202.py.snap | 3 +- ..._flake8_2020__tests__YTT203_YTT203.py.snap | 3 +- ..._flake8_2020__tests__YTT204_YTT204.py.snap | 3 +- ..._flake8_2020__tests__YTT301_YTT301.py.snap | 3 +- ..._flake8_2020__tests__YTT302_YTT302.py.snap | 3 +- ..._flake8_2020__tests__YTT303_YTT303.py.snap | 3 +- ...otations__tests__ignore_fully_untyped.snap | 3 +- ...otations__tests__simple_magic_methods.snap | 27 ++-- ...e8_async__tests__ASYNC105_ASYNC105.py.snap | 5 +- ...e8_async__tests__ASYNC115_ASYNC115.py.snap | 21 ++- ...e8_async__tests__ASYNC116_ASYNC116.py.snap | 13 +- ...e8_async__tests__ASYNC210_ASYNC210.py.snap | 17 +-- ...e8_async__tests__ASYNC220_ASYNC22x.py.snap | 5 +- ...e8_async__tests__ASYNC221_ASYNC22x.py.snap | 17 +-- ...e8_async__tests__ASYNC222_ASYNC22x.py.snap | 3 +- ...e8_async__tests__ASYNC230_ASYNC230.py.snap | 13 +- ...s__flake8_bandit__tests__S102_S102.py.snap | 5 +- ...s__flake8_bandit__tests__S103_S103.py.snap | 3 +- ...s__flake8_bandit__tests__S105_S105.py.snap | 17 +-- ...s__flake8_bandit__tests__S108_S108.py.snap | 13 +- ...es__flake8_bandit__tests__S108_extend.snap | 13 +- ...s__flake8_bandit__tests__S110_S110.py.snap | 5 +- ...les__flake8_bandit__tests__S110_typed.snap | 5 +- ...s__flake8_bandit__tests__S112_S112.py.snap | 9 +- ...s__flake8_bandit__tests__S113_S113.py.snap | 9 +- ...s__flake8_bandit__tests__S201_S201.py.snap | 3 +- ...s__flake8_bandit__tests__S301_S301.py.snap | 3 +- ...s__flake8_bandit__tests__S307_S307.py.snap | 3 +- ...s__flake8_bandit__tests__S310_S310.py.snap | 9 +- ...s__flake8_bandit__tests__S311_S311.py.snap | 3 +- ...s__flake8_bandit__tests__S312_S312.py.snap | 3 +- ...s__flake8_bandit__tests__S324_S324.py.snap | 11 +- ...s__flake8_bandit__tests__S501_S501.py.snap | 3 +- ...s__flake8_bandit__tests__S502_S502.py.snap | 5 +- ...s__flake8_bandit__tests__S504_S504.py.snap | 3 +- ...s__flake8_bandit__tests__S505_S505.py.snap | 3 +- ...s__flake8_bandit__tests__S506_S506.py.snap | 3 +- ...s__flake8_bandit__tests__S507_S507.py.snap | 3 +- ...s__flake8_bandit__tests__S508_S508.py.snap | 5 +- ...s__flake8_bandit__tests__S509_S509.py.snap | 3 +- ...s__flake8_bandit__tests__S601_S601.py.snap | 3 +- ...s__flake8_bandit__tests__S602_S602.py.snap | 5 +- ...s__flake8_bandit__tests__S603_S603.py.snap | 7 +- ...s__flake8_bandit__tests__S607_S607.py.snap | 3 +- ...s__flake8_bandit__tests__S609_S609.py.snap | 3 +- ...s__flake8_bandit__tests__S610_S610.py.snap | 13 +- ...s__flake8_bandit__tests__S612_S612.py.snap | 5 +- ...s__flake8_bandit__tests__S701_S701.py.snap | 5 +- ...s__flake8_bandit__tests__S702_S702.py.snap | 5 +- ...__flake8_bugbear__tests__B003_B003.py.snap | 3 +- ...__flake8_bugbear__tests__B004_B004.py.snap | 3 +- ...__flake8_bugbear__tests__B005_B005.py.snap | 3 +- ...flake8_bugbear__tests__B006_B006_1.py.snap | 3 +- ...flake8_bugbear__tests__B006_B006_2.py.snap | 3 +- ...flake8_bugbear__tests__B006_B006_6.py.snap | 3 +- ...flake8_bugbear__tests__B006_B006_7.py.snap | 3 +- ...ke8_bugbear__tests__B006_B006_B008.py.snap | 5 +- ...__flake8_bugbear__tests__B007_B007.py.snap | 9 +- ...ke8_bugbear__tests__B009_B009_B010.py.snap | 5 +- ...ke8_bugbear__tests__B010_B009_B010.py.snap | 3 +- ...__flake8_bugbear__tests__B012_B012.py.snap | 9 +- ...__flake8_bugbear__tests__B015_B015.py.snap | 9 +- ...__flake8_bugbear__tests__B016_B016.py.snap | 3 +- ...__flake8_bugbear__tests__B017_B017.py.snap | 5 +- ...__flake8_bugbear__tests__B019_B019.py.snap | 15 +- ...__flake8_bugbear__tests__B020_B020.py.snap | 5 +- ...__flake8_bugbear__tests__B021_B021.py.snap | 3 +- ...__flake8_bugbear__tests__B022_B022.py.snap | 5 +- ...__flake8_bugbear__tests__B023_B023.py.snap | 15 +- ...__flake8_bugbear__tests__B028_B028.py.snap | 5 +- ...__flake8_bugbear__tests__B029_B029.py.snap | 7 +- ...__flake8_bugbear__tests__B031_B031.py.snap | 21 ++- ...__flake8_bugbear__tests__B032_B032.py.snap | 11 +- ...__flake8_bugbear__tests__B033_B033.py.snap | 3 +- ...__flake8_bugbear__tests__B034_B034.py.snap | 3 +- ...__flake8_bugbear__tests__B039_B039.py.snap | 7 +- ...__flake8_bugbear__tests__B901_B901.py.snap | 5 +- ...ests__B903_class_as_data_structure.py.snap | 14 +- ...__flake8_bugbear__tests__B904_B904.py.snap | 5 +- ...rules__flake8_bugbear__tests__B905.py.snap | 5 +- ...__flake8_bugbear__tests__B909_B909.py.snap | 15 +- ...__flake8_bugbear__tests__B911_B911.py.snap | 13 +- ..._flake8_builtins__tests__A001_A001.py.snap | 27 ++-- ...sts__A001_A001.py_builtins_ignorelist.snap | 23 ++- ..._flake8_builtins__tests__A003_A003.py.snap | 5 +- ...sts__A003_A003.py_builtins_ignorelist.snap | 3 +- ..._flake8_builtins__tests__A004_A004.py.snap | 3 +- ...e8_builtins__tests__A004_A004.py_py38.snap | 3 +- ..._flake8_builtins__tests__A006_A006.py.snap | 3 +- ..._commas__tests__COM81_syntax_error.py.snap | 5 +- ...8_comprehensions__tests__C400_C400.py.snap | 4 +- ...8_comprehensions__tests__C401_C401.py.snap | 4 +- ...8_comprehensions__tests__C402_C402.py.snap | 16 +- ...8_comprehensions__tests__C403_C403.py.snap | 24 +-- ...8_comprehensions__tests__C404_C404.py.snap | 12 +- ...8_comprehensions__tests__C405_C405.py.snap | 6 +- ...8_comprehensions__tests__C408_C408.py.snap | 18 +-- ...low_dict_calls_with_keyword_arguments.snap | 8 +- ...8_comprehensions__tests__C409_C409.py.snap | 18 +-- ...8_comprehensions__tests__C410_C410.py.snap | 4 +- ...8_comprehensions__tests__C413_C413.py.snap | 4 +- ...8_comprehensions__tests__C414_C414.py.snap | 6 +- ...8_comprehensions__tests__C416_C416.py.snap | 5 +- ...8_comprehensions__tests__C417_C417.py.snap | 8 +- ...8_comprehensions__tests__C418_C418.py.snap | 2 +- ...8_comprehensions__tests__C420_C420.py.snap | 3 +- ...ensions__tests__preview__C409_C409.py.snap | 20 +-- ...e8_datetimez__tests__DTZ001_DTZ001.py.snap | 11 +- ...e8_datetimez__tests__DTZ002_DTZ002.py.snap | 5 +- ...e8_datetimez__tests__DTZ003_DTZ003.py.snap | 5 +- ...e8_datetimez__tests__DTZ004_DTZ004.py.snap | 5 +- ...e8_datetimez__tests__DTZ005_DTZ005.py.snap | 11 +- ...e8_datetimez__tests__DTZ006_DTZ006.py.snap | 11 +- ...e8_datetimez__tests__DTZ007_DTZ007.py.snap | 11 +- ...e8_datetimez__tests__DTZ011_DTZ011.py.snap | 3 +- ...e8_datetimez__tests__DTZ012_DTZ012.py.snap | 3 +- ...e8_datetimez__tests__DTZ901_DTZ901.py.snap | 9 +- ..._flake8_debugger__tests__T100_T100.py.snap | 9 +- ...flake8_executable__tests__EXE001_1.py.snap | 3 +- ...flake8_executable__tests__EXE004_4.py.snap | 4 +- ...me__tests__line-contains-fixme_T00.py.snap | 3 +- ...xme__tests__line-contains-todo_T00.py.snap | 3 +- ...icit_str_concat__tests__ISC001_ISC.py.snap | 33 ++-- ...icit_str_concat__tests__ISC002_ISC.py.snap | 7 +- ...oncat__tests__multiline_ISC001_ISC.py.snap | 33 ++-- ...ke8_import_conventions__tests__custom.snap | 9 +- ...ort_conventions__tests__custom_banned.snap | 7 +- ...onventions__tests__custom_banned_from.snap | 7 +- ...port_conventions__tests__from_imports.snap | 3 +- ...conventions__tests__override_defaults.snap | 9 +- ...t_conventions__tests__remove_defaults.snap | 9 +- ...ake8_logging__tests__LOG001_LOG001.py.snap | 3 +- ...ake8_logging__tests__LOG002_LOG002.py.snap | 5 +- ...ake8_logging__tests__LOG007_LOG007.py.snap | 3 +- ...ake8_logging__tests__LOG009_LOG009.py.snap | 5 +- ...ake8_logging__tests__LOG015_LOG015.py.snap | 5 +- ...flake8_logging_format__tests__G001.py.snap | 11 +- ...flake8_logging_format__tests__G002.py.snap | 7 +- ...flake8_logging_format__tests__G003.py.snap | 7 +- ...flake8_logging_format__tests__G004.py.snap | 11 +- ...flake8_logging_format__tests__G010.py.snap | 9 +- ...flake8_logging_format__tests__G201.py.snap | 9 +- ...flake8_logging_format__tests__G202.py.snap | 9 +- ...__flake8_pie__tests__PIE790_PIE790.py.snap | 33 ++-- ...__flake8_pie__tests__PIE794_PIE794.py.snap | 5 +- ...__flake8_pie__tests__PIE800_PIE800.py.snap | 89 ++++++----- ...__flake8_pie__tests__PIE804_PIE804.py.snap | 29 ++-- ...__flake8_pie__tests__PIE808_PIE808.py.snap | 5 +- ...__flake8_pie__tests__PIE810_PIE810.py.snap | 7 +- ...es__flake8_print__tests__T201_T201.py.snap | 5 +- ...es__flake8_print__tests__T203_T203.py.snap | 9 +- ..._flake8_pyi__tests__PYI001_PYI001.pyi.snap | 13 +- ..._flake8_pyi__tests__PYI002_PYI002.pyi.snap | 3 +- ..._flake8_pyi__tests__PYI004_PYI004.pyi.snap | 5 +- ..._flake8_pyi__tests__PYI005_PYI005.pyi.snap | 3 +- ...__flake8_pyi__tests__PYI006_PYI006.py.snap | 23 ++- ..._flake8_pyi__tests__PYI006_PYI006.pyi.snap | 23 ++- ..._flake8_pyi__tests__PYI007_PYI007.pyi.snap | 11 +- ..._flake8_pyi__tests__PYI008_PYI008.pyi.snap | 5 +- ..._flake8_pyi__tests__PYI009_PYI009.pyi.snap | 3 +- ..._flake8_pyi__tests__PYI010_PYI010.pyi.snap | 7 +- ..._flake8_pyi__tests__PYI012_PYI012.pyi.snap | 11 +- ...__flake8_pyi__tests__PYI013_PYI013.py.snap | 5 +- ..._flake8_pyi__tests__PYI013_PYI013.pyi.snap | 13 +- ..._flake8_pyi__tests__PYI015_PYI015.pyi.snap | 3 +- ...__flake8_pyi__tests__PYI016_PYI016.py.snap | 5 +- ..._flake8_pyi__tests__PYI017_PYI017.pyi.snap | 17 +-- ...__flake8_pyi__tests__PYI018_PYI018.py.snap | 5 +- ..._flake8_pyi__tests__PYI018_PYI018.pyi.snap | 5 +- ...__flake8_pyi__tests__PYI019_PYI019.py.snap | 49 +++--- ..._flake8_pyi__tests__PYI019_PYI019.pyi.snap | 49 +++--- ..._flake8_pyi__tests__PYI020_PYI020.pyi.snap | 13 +- ...__flake8_pyi__tests__PYI024_PYI024.py.snap | 11 +- ..._flake8_pyi__tests__PYI024_PYI024.pyi.snap | 11 +- ...flake8_pyi__tests__PYI025_PYI025_1.py.snap | 3 +- ...lake8_pyi__tests__PYI025_PYI025_1.pyi.snap | 11 +- ...flake8_pyi__tests__PYI025_PYI025_2.py.snap | 5 +- ...lake8_pyi__tests__PYI025_PYI025_2.pyi.snap | 5 +- ...flake8_pyi__tests__PYI025_PYI025_3.py.snap | 3 +- ...lake8_pyi__tests__PYI025_PYI025_3.pyi.snap | 3 +- ..._flake8_pyi__tests__PYI026_PYI026.pyi.snap | 7 +- ..._flake8_pyi__tests__PYI029_PYI029.pyi.snap | 5 +- ...__flake8_pyi__tests__PYI030_PYI030.py.snap | 41 +++-- ..._flake8_pyi__tests__PYI030_PYI030.pyi.snap | 37 +++-- ..._flake8_pyi__tests__PYI035_PYI035.pyi.snap | 5 +- ...__flake8_pyi__tests__PYI042_PYI042.py.snap | 5 +- ..._flake8_pyi__tests__PYI042_PYI042.pyi.snap | 5 +- ...__flake8_pyi__tests__PYI043_PYI043.py.snap | 3 +- ..._flake8_pyi__tests__PYI043_PYI043.pyi.snap | 3 +- ..._flake8_pyi__tests__PYI044_PYI044.pyi.snap | 3 +- ..._flake8_pyi__tests__PYI045_PYI045.pyi.snap | 5 +- ...__flake8_pyi__tests__PYI047_PYI047.py.snap | 7 +- ..._flake8_pyi__tests__PYI047_PYI047.pyi.snap | 7 +- ..._flake8_pyi__tests__PYI048_PYI048.pyi.snap | 7 +- ..._flake8_pyi__tests__PYI049_PYI049.pyi.snap | 3 +- ...__flake8_pyi__tests__PYI051_PYI051.py.snap | 13 +- ..._flake8_pyi__tests__PYI051_PYI051.pyi.snap | 13 +- ..._flake8_pyi__tests__PYI053_PYI053.pyi.snap | 16 +- ..._flake8_pyi__tests__PYI054_PYI054.pyi.snap | 7 +- ..._flake8_pyi__tests__PYI055_PYI055.pyi.snap | 10 +- ...__flake8_pyi__tests__PYI056_PYI056.py.snap | 3 +- ..._flake8_pyi__tests__PYI056_PYI056.pyi.snap | 3 +- ...__flake8_pyi__tests__PYI057_PYI057.py.snap | 3 +- ..._flake8_pyi__tests__PYI057_PYI057.pyi.snap | 3 +- ..._flake8_pyi__tests__PYI058_PYI058.pyi.snap | 17 +-- ...__flake8_pyi__tests__PYI059_PYI059.py.snap | 5 +- ..._flake8_pyi__tests__PYI059_PYI059.pyi.snap | 5 +- ...__flake8_pyi__tests__PYI061_PYI061.py.snap | 11 +- ..._flake8_pyi__tests__PYI061_PYI061.pyi.snap | 5 +- ...__flake8_pyi__tests__PYI062_PYI062.py.snap | 20 +-- ..._flake8_pyi__tests__PYI062_PYI062.pyi.snap | 20 +-- ...__flake8_pyi__tests__PYI063_PYI063.py.snap | 10 +- ..._flake8_pyi__tests__PYI063_PYI063.pyi.snap | 10 +- ...__flake8_pyi__tests__PYI064_PYI064.py.snap | 9 +- ..._flake8_pyi__tests__PYI064_PYI064.pyi.snap | 9 +- ...sts__custom_classmethod_rules_preview.snap | 49 +++--- ...yi__tests__preview__PYI044_PYI044.pyi.snap | 3 +- ...e8_pyi__tests__py38_PYI026_PYI026.pyi.snap | 7 +- ...e8_pytest_style__tests__PT001_default.snap | 7 +- ..._pytest_style__tests__PT006_and_PT007.snap | 7 +- ...e8_pytest_style__tests__PT006_default.snap | 2 +- ...lake8_pytest_style__tests__PT006_list.snap | 2 +- ...es__flake8_pytest_style__tests__PT008.snap | 11 +- ...es__flake8_pytest_style__tests__PT009.snap | 47 +++--- ...e8_pytest_style__tests__PT011_default.snap | 9 +- ..._tests__PT011_extend_broad_exceptions.snap | 9 +- ...8_pytest_style__tests__PT011_glob_all.snap | 13 +- ...ytest_style__tests__PT011_glob_prefix.snap | 5 +- ...es__flake8_pytest_style__tests__PT013.snap | 3 +- ..._tests__only_docstring_doubles_all.py.snap | 3 +- ...es__tests__only_inline_doubles_all.py.snap | 5 +- ..._tests__only_multiline_doubles_all.py.snap | 3 +- ...ubles_over_docstring_doubles_class.py.snap | 5 +- ...ocstring_doubles_module_singleline.py.snap | 3 +- ...ubles_over_docstring_singles_class.py.snap | 3 +- ...g_singles_mixed_quotes_class_var_1.py.snap | 5 +- ...g_singles_mixed_quotes_class_var_2.py.snap | 5 +- ...xed_quotes_module_singleline_var_1.py.snap | 5 +- ...xed_quotes_module_singleline_var_2.py.snap | 5 +- ...ngles_over_docstring_doubles_class.py.snap | 3 +- ...g_doubles_mixed_quotes_class_var_1.py.snap | 3 +- ...g_doubles_mixed_quotes_class_var_2.py.snap | 3 +- ...xed_quotes_module_singleline_var_1.py.snap | 3 +- ...xed_quotes_module_singleline_var_2.py.snap | 3 +- ...ngles_over_docstring_singles_class.py.snap | 5 +- ...ocstring_singles_module_singleline.py.snap | 3 +- ...quire_doubles_over_singles_escaped.py.snap | 5 +- ...s_over_singles_escaped_unnecessary.py.snap | 11 +- ...bles_over_singles_multiline_string.py.snap | 3 +- ...quire_singles_over_doubles_escaped.py.snap | 5 +- ...s_over_doubles_escaped_unnecessary.py.snap | 9 +- ...gles_over_doubles_multiline_string.py.snap | 3 +- ...ry-paren-on-raise-exception_RSE102.py.snap | 35 +++-- ...lake8_return__tests__RET501_RET501.py.snap | 3 +- ...lake8_return__tests__RET505_RET505.py.snap | 3 +- ...ests__private-member-access_SLF001.py.snap | 5 +- ...ke8_simplify__tests__SIM101_SIM101.py.snap | 17 +-- ...ke8_simplify__tests__SIM112_SIM112.py.snap | 27 ++-- ...ke8_simplify__tests__SIM115_SIM115.py.snap | 7 +- ...ke8_simplify__tests__SIM116_SIM116.py.snap | 15 +- ...ke8_simplify__tests__SIM118_SIM118.py.snap | 61 ++++---- ...ke8_simplify__tests__SIM208_SIM208.py.snap | 13 +- ...ke8_simplify__tests__SIM210_SIM210.py.snap | 13 +- ...ke8_simplify__tests__SIM211_SIM211.py.snap | 11 +- ...ke8_simplify__tests__SIM212_SIM212.py.snap | 7 +- ...ke8_simplify__tests__SIM220_SIM220.py.snap | 5 +- ...ke8_simplify__tests__SIM221_SIM221.py.snap | 5 +- ...ke8_simplify__tests__SIM222_SIM222.py.snap | 137 +++++++++-------- ...ke8_simplify__tests__SIM223_SIM223.py.snap | 137 +++++++++-------- ...ke8_simplify__tests__SIM300_SIM300.py.snap | 5 +- ...ke8_simplify__tests__SIM905_SIM905.py.snap | 17 +-- ...ke8_simplify__tests__SIM910_SIM910.py.snap | 15 +- ...ify__tests__preview__SIM108_SIM108.py.snap | 20 ++- ...ake8_slots__tests__SLOT001_SLOT001.py.snap | 3 +- ...ts__tests__ban_parent_imports_package.snap | 3 +- ...lake8_tidy_imports__tests__banned_api.snap | 39 +++-- ...dy_imports__tests__banned_api_package.snap | 5 +- ...s__tests__banned_module_level_imports.snap | 27 ++-- ...os__tests__missing-todo-link_TD003.py.snap | 11 +- ...s__empty-type-checking-block_TC005.py.snap | 5 +- ..._type_checking__tests__exempt_modules.snap | 3 +- ...sts__multiple_modules_different_types.snap | 9 +- ...ng__tests__multiple_modules_same_type.snap | 9 +- ...ype_checking__tests__no_typing_import.snap | 5 +- ...mport-in-type-checking-block_quote.py.snap | 4 +- ...ping-only-third-party-import_quote.py.snap | 29 ++-- ...ing-only-third-party-import_quote2.py.snap | 31 ++-- ...ng__tests__quoted-type-alias_TC008.py.snap | 8 +- ...ias_TC008_typing_execution_context.py.snap | 2 +- ...rt-in-type-checking-block_TC004_11.py.snap | 3 +- ...rt-in-type-checking-block_TC004_12.py.snap | 3 +- ...ort-in-type-checking-block_TC004_9.py.snap | 5 +- ...in-type-checking-block_module__app.py.snap | 2 +- ...mport-in-type-checking-block_quote.py.snap | 4 +- ...k_runtime_evaluated_base_classes_1.py.snap | 5 +- ...ock_runtime_evaluated_decorators_1.py.snap | 5 +- ...ests__runtime-string-union_TC010_1.py.snap | 3 +- ...ests__runtime-string-union_TC010_2.py.snap | 5 +- ...y-standard-library-import_init_var.py.snap | 3 +- ...ly-standard-library-import_kw_only.py.snap | 3 +- ...ing-only-third-party-import_strict.py.snap | 9 +- ...g__tests__tc004_precedence_over_tc007.snap | 2 +- ...g__tests__tc010_precedence_over_tc008.snap | 2 +- ...ests__type_checking_block_after_usage.snap | 5 +- ...g__tests__type_checking_block_comment.snap | 5 +- ...ng__tests__type_checking_block_inline.snap | 5 +- ...__tests__type_checking_block_own_line.snap | 5 +- ...ping-only-first-party-import_TC001.py.snap | 3 +- ...only-standard-library-import_TC003.py.snap | 3 +- ...rary-import_exempt_type_checking_1.py.snap | 5 +- ...rary-import_exempt_type_checking_2.py.snap | 5 +- ...rary-import_exempt_type_checking_3.py.snap | 5 +- ...d-library-import_module__undefined.py.snap | 3 +- ...t_runtime_evaluated_base_classes_3.py.snap | 3 +- ...ping-only-third-party-import_TC002.py.snap | 21 ++- ...t_runtime_evaluated_base_classes_2.py.snap | 3 +- ...ort_runtime_evaluated_decorators_2.py.snap | 3 +- ...-third-party-import_singledispatch.py.snap | 3 +- ...ing-only-third-party-import_strict.py.snap | 3 +- ...hird-party-import_typing_modules_1.py.snap | 3 +- ...hird-party-import_typing_modules_2.py.snap | 3 +- ...s__typing_import_after_package_import.snap | 5 +- ...ing__tests__typing_import_after_usage.snap | 5 +- ...__typing_import_before_package_import.snap | 5 +- ...__tests__unquoted-type-alias_TC007.py.snap | 2 +- ...nused_arguments__tests__ARG002_ARG.py.snap | 11 +- ...nused_arguments__tests__ARG005_ARG.py.snap | 3 +- ...uments__tests__enforce_variadic_names.snap | 9 +- ...guments__tests__ignore_variadic_names.snap | 5 +- ...e_pathlib__tests__PTH124_py_path_1.py.snap | 3 +- ...e_pathlib__tests__PTH124_py_path_2.py.snap | 3 +- ..._use_pathlib__tests__PTH202_PTH202.py.snap | 5 +- ..._use_pathlib__tests__PTH203_PTH203.py.snap | 3 +- ..._use_pathlib__tests__PTH205_PTH205.py.snap | 5 +- ..._use_pathlib__tests__PTH206_PTH206.py.snap | 3 +- ..._use_pathlib__tests__PTH208_PTH208.py.snap | 9 +- ..._use_pathlib__tests__PTH210_PTH210.py.snap | 21 ++- ...se_pathlib__tests__PTH210_PTH210_1.py.snap | 13 +- ...ake8_use_pathlib__tests__full_name.py.snap | 5 +- ...ake8_use_pathlib__tests__import_as.py.snap | 3 +- ...e8_use_pathlib__tests__import_from.py.snap | 3 +- ...use_pathlib__tests__import_from_as.py.snap | 3 +- ...rules__flynt__tests__FLY002_FLY002.py.snap | 3 +- ...ules__isort__tests__leading_prefix.py.snap | 7 +- ...ort__tests__required_import_unused.py.snap | 5 +- ...ules__mccabe__tests__max_complexity_0.snap | 9 +- ...__numpy-deprecated-function_NPY003.py.snap | 5 +- ...numpy-deprecated-type-alias_NPY001.py.snap | 19 ++- ..._tests__numpy-legacy-random_NPY002.py.snap | 5 +- ...__tests__numpy2-deprecation_NPY201.py.snap | 141 +++++++++--------- ...tests__numpy2-deprecation_NPY201_2.py.snap | 111 +++++++------- ...tests__numpy2-deprecation_NPY201_3.py.snap | 27 ++-- ...es__pandas_vet__tests__PD002_PD002.py.snap | 23 ++- ...PD012_pandas_use_of_dot_read_table.py.snap | 3 +- ...es__pandas_vet__tests__PD101_PD101.py.snap | 3 +- ...les__pep8_naming__tests__N802_N802.py.snap | 3 +- ...les__pep8_naming__tests__N804_N804.py.snap | 13 +- ...les__pep8_naming__tests__N805_N805.py.snap | 13 +- ...les__pep8_naming__tests__N806_N806.py.snap | 7 +- ...les__pep8_naming__tests__N811_N811.py.snap | 2 +- ...les__pep8_naming__tests__N814_N814.py.snap | 2 +- ...case_imported_as_incorrect_convention.snap | 3 +- ...naming__tests__classmethod_decorators.snap | 13 +- ...ing__tests__ignore_names_N801_N801.py.snap | 5 +- ...ing__tests__ignore_names_N802_N802.py.snap | 5 +- ...ing__tests__ignore_names_N803_N803.py.snap | 5 +- ...ing__tests__ignore_names_N804_N804.py.snap | 3 +- ...ing__tests__ignore_names_N805_N805.py.snap | 9 +- ...ing__tests__ignore_names_N806_N806.py.snap | 3 +- ...ing__tests__ignore_names_N807_N807.py.snap | 5 +- ...ing__tests__ignore_names_N811_N811.py.snap | 3 +- ...ing__tests__ignore_names_N812_N812.py.snap | 3 +- ...ing__tests__ignore_names_N813_N813.py.snap | 5 +- ...ing__tests__ignore_names_N814_N814.py.snap | 5 +- ...ing__tests__ignore_names_N815_N815.py.snap | 11 +- ...ing__tests__ignore_names_N816_N816.py.snap | 5 +- ...ing__tests__ignore_names_N817_N817.py.snap | 3 +- ...ing__tests__ignore_names_N818_N818.py.snap | 5 +- ...aming__tests__staticmethod_decorators.snap | 13 +- ...__perflint__tests__PERF101_PERF101.py.snap | 23 ++- ...les__pycodestyle__tests__E101_E101.py.snap | 5 +- ...ules__pycodestyle__tests__E201_E20.py.snap | 5 +- ...ules__pycodestyle__tests__E202_E20.py.snap | 3 +- ...ules__pycodestyle__tests__E203_E20.py.snap | 17 +-- ...ules__pycodestyle__tests__E221_E22.py.snap | 3 +- ...ules__pycodestyle__tests__E222_E22.py.snap | 3 +- ...ules__pycodestyle__tests__E252_E25.py.snap | 21 ++- ...ules__pycodestyle__tests__E262_E26.py.snap | 9 +- ...ules__pycodestyle__tests__E265_E26.py.snap | 7 +- ...ules__pycodestyle__tests__E266_E26.py.snap | 7 +- ...ules__pycodestyle__tests__E271_E27.py.snap | 3 +- ...ules__pycodestyle__tests__E273_E27.py.snap | 3 +- ...tyle__tests__E301_E30_syntax_error.py.snap | 9 +- ...ules__pycodestyle__tests__E302_E30.py.snap | 11 +- ...ts__E302_E302_first_line_docstring.py.snap | 3 +- ...s__E302_E302_first_line_expression.py.snap | 3 +- ...sts__E302_E302_first_line_function.py.snap | 3 +- ...ts__E302_E302_first_line_statement.py.snap | 3 +- ...tyle__tests__E302_E30_syntax_error.py.snap | 11 +- ...ules__pycodestyle__tests__E303_E30.py.snap | 9 +- ...tyle__tests__E303_E30_syntax_error.py.snap | 9 +- ...ules__pycodestyle__tests__E304_E30.py.snap | 3 +- ...ules__pycodestyle__tests__E305_E30.py.snap | 5 +- ...tyle__tests__E305_E30_syntax_error.py.snap | 11 +- ...tyle__tests__E306_E30_syntax_error.py.snap | 9 +- ...ules__pycodestyle__tests__E401_E40.py.snap | 17 +-- ...ules__pycodestyle__tests__E402_E40.py.snap | 13 +- ...__pycodestyle__tests__E402_E402.ipynb.snap | 9 +- ...s__pycodestyle__tests__E402_E402_0.py.snap | 7 +- ...s__pycodestyle__tests__E402_E402_1.py.snap | 7 +- ...les__pycodestyle__tests__E711_E711.py.snap | 5 +- ...les__pycodestyle__tests__E712_E712.py.snap | 9 +- ...les__pycodestyle__tests__E721_E721.py.snap | 5 +- ...les__pycodestyle__tests__E741_E741.py.snap | 17 +-- ...les__pycodestyle__tests__W291_W291.py.snap | 3 +- ...s__pycodestyle__tests__W605_W605_0.py.snap | 13 +- ...s__pycodestyle__tests__W605_W605_1.py.snap | 10 +- ...yle__tests__blank_lines_E302_notebook.snap | 3 +- ...yle__tests__blank_lines_E303_notebook.snap | 3 +- ...yle__tests__blank_lines_E304_notebook.snap | 3 +- ...s__pycodestyle__tests__max_doc_length.snap | 13 +- ...yle__tests__max_doc_length_with_utf_8.snap | 13 +- ...destyle__tests__preview__E502_E502.py.snap | 5 +- ...style__tests__preview__W391_W391_0.py.snap | 3 +- ...rules__pycodestyle__tests__tab_size_1.snap | 3 +- ...rules__pycodestyle__tests__tab_size_2.snap | 3 +- ...rules__pycodestyle__tests__tab_size_4.snap | 3 +- ...rules__pycodestyle__tests__tab_size_8.snap | 3 +- ...__rules__pydocstyle__tests__D101_D.py.snap | 3 +- ...__rules__pydocstyle__tests__D107_D.py.snap | 3 +- ...ules__pydocstyle__tests__D202_D202.py.snap | 3 +- ...__rules__pydocstyle__tests__D204_D.py.snap | 3 +- ...__rules__pydocstyle__tests__D211_D.py.snap | 5 +- ...ydocstyle__tests__D214_D214_module.py.snap | 5 +- ...__pydocstyle__tests__D214_sections.py.snap | 5 +- ...ules__pydocstyle__tests__D402_D402.py.snap | 3 +- ...__rules__pydocstyle__tests__D404_D.py.snap | 5 +- ...__pydocstyle__tests__D405_sections.py.snap | 6 +- ...__pydocstyle__tests__D406_sections.py.snap | 4 +- ...__pydocstyle__tests__D407_sections.py.snap | 10 +- ...__pydocstyle__tests__D408_sections.py.snap | 3 +- ...ules__pydocstyle__tests__D410_D410.py.snap | 5 +- ...__pydocstyle__tests__D410_sections.py.snap | 5 +- ...__pydocstyle__tests__D412_sections.py.snap | 3 +- ...ules__pydocstyle__tests__D413_D413.py.snap | 9 +- ...__pydocstyle__tests__D413_sections.py.snap | 18 +-- ...__pydocstyle__tests__D414_sections.py.snap | 17 +-- ...__pydocstyle__tests__D417_sections.py.snap | 3 +- ...__rules__pydocstyle__tests__D419_D.py.snap | 3 +- ...rules__pydocstyle__tests__d417_google.snap | 3 +- ...__pydocstyle__tests__d417_unspecified.snap | 3 +- ...417_unspecified_ignore_var_parameters.snap | 3 +- ...ules__pyflakes__tests__F401_F401_0.py.snap | 15 +- ...les__pyflakes__tests__F401_F401_10.py.snap | 5 +- ...les__pyflakes__tests__F401_F401_17.py.snap | 5 +- ...ules__pyflakes__tests__F401_F401_6.py.snap | 7 +- ...F401_29__all_conditional____init__.py.snap | 9 +- ...ts__F401_deprecated_option_F401_30.py.snap | 3 +- ...F401_29__all_conditional____init__.py.snap | 9 +- ..._rules__pyflakes__tests__F402_F402.py.snap | 3 +- ..._rules__pyflakes__tests__F403_F403.py.snap | 3 +- ...ules__pyflakes__tests__F404_F404_0.py.snap | 5 +- ...ules__pyflakes__tests__F404_F404_1.py.snap | 3 +- ..._rules__pyflakes__tests__F405_F405.py.snap | 3 +- ..._rules__pyflakes__tests__F504_F504.py.snap | 11 +- ..._rules__pyflakes__tests__F506_F50x.py.snap | 3 +- ..._rules__pyflakes__tests__F508_F50x.py.snap | 3 +- ..._rules__pyflakes__tests__F521_F521.py.snap | 3 +- ..._rules__pyflakes__tests__F523_F523.py.snap | 12 +- ..._rules__pyflakes__tests__F541_F541.py.snap | 5 +- ..._rules__pyflakes__tests__F601_F601.py.snap | 11 +- ..._rules__pyflakes__tests__F602_F602.py.snap | 3 +- ..._rules__pyflakes__tests__F632_F632.py.snap | 21 ++- ..._rules__pyflakes__tests__F633_F633.py.snap | 3 +- ..._rules__pyflakes__tests__F634_F634.py.snap | 3 +- ..._rules__pyflakes__tests__F701_F701.py.snap | 5 +- ..._rules__pyflakes__tests__F702_F702.py.snap | 5 +- ...les__pyflakes__tests__F811_F811_17.py.snap | 3 +- ...les__pyflakes__tests__F811_F811_26.py.snap | 3 +- ...les__pyflakes__tests__F811_F811_28.py.snap | 3 +- ...es__pyflakes__tests__F811_F811_29.pyi.snap | 3 +- ...les__pyflakes__tests__F811_F811_30.py.snap | 7 +- ...les__pyflakes__tests__F811_F811_31.py.snap | 3 +- ...ules__pyflakes__tests__F821_F821_0.py.snap | 7 +- ...les__pyflakes__tests__F821_F821_13.py.snap | 3 +- ...ules__pyflakes__tests__F821_F821_2.py.snap | 3 +- ...les__pyflakes__tests__F821_F821_20.py.snap | 5 +- ...les__pyflakes__tests__F821_F821_28.py.snap | 3 +- ...ules__pyflakes__tests__F821_F821_3.py.snap | 5 +- ...ules__pyflakes__tests__F821_F821_4.py.snap | 11 +- ...ules__pyflakes__tests__F822_F822_0.py.snap | 3 +- ...les__pyflakes__tests__F822_F822_0.pyi.snap | 3 +- ...ules__pyflakes__tests__F822_F822_1.py.snap | 3 +- ...les__pyflakes__tests__F822_F822_1b.py.snap | 3 +- ..._rules__pyflakes__tests__F823_F823.py.snap | 5 +- ...ules__pyflakes__tests__F841_F841_0.py.snap | 11 +- ...ules__pyflakes__tests__F841_F841_3.py.snap | 19 ++- ...hadowed_global_import_in_global_scope.snap | 3 +- ...shadowed_global_import_in_local_scope.snap | 5 +- ...shadowed_import_shadow_in_local_scope.snap | 3 +- ..._shadowed_local_import_in_local_scope.snap | 3 +- ...lakes__tests__f841_dummy_variable_rgx.snap | 11 +- ..._linter__rules__pyflakes__tests__init.snap | 3 +- ...yflakes__tests__multi_statement_lines.snap | 15 +- ...F401_29__all_conditional____init__.py.snap | 9 +- ...kes__tests__preview__F401___init__.py.snap | 3 +- ...kes__tests__preview__F822___init__.py.snap | 7 +- ...grep_hooks__tests__PGH003_PGH003_0.py.snap | 3 +- ...grep_hooks__tests__PGH003_PGH003_1.py.snap | 3 +- ...grep_hooks__tests__PGH004_PGH004_0.py.snap | 9 +- ...grep_hooks__tests__PGH005_PGH005_0.py.snap | 3 +- ...C0105_type_name_incorrect_variance.py.snap | 13 +- ...nt__tests__PLC0131_type_bivariance.py.snap | 9 +- ...__PLC0132_type_param_name_mismatch.py.snap | 17 +-- ...tests__PLC0205_single_string_slots.py.snap | 7 +- ...__PLC0206_dict_index_missing_items.py.snap | 23 ++- ..._tests__PLC0208_iteration_over_set.py.snap | 25 ++-- ...nt__tests__PLC0414_import_aliasing.py.snap | 3 +- ...__PLC0415_import_outside_top_level.py.snap | 3 +- ...t__tests__PLC1802_len_as_condition.py.snap | 25 ++-- ...s__PLC1901_compare_to_empty_string.py.snap | 7 +- ...int__tests__PLC2401_non_ascii_name.py.snap | 9 +- ...s__PLC2403_non_ascii_module_import.py.snap | 7 +- ..._private_name__submodule____main__.py.snap | 3 +- ...s__PLC2801_unnecessary_dunder_call.py.snap | 24 +-- ...002_unnecessary_direct_lambda_call.py.snap | 3 +- ...lint__tests__PLE0100_yield_in_init.py.snap | 3 +- ...int__tests__PLE0101_return_in_init.py.snap | 5 +- ...118_load_before_global_declaration.py.snap | 37 +++-- ...nexpected_special_method_signature.py.snap | 15 +- ...__PLE0304_invalid_return_type_bool.py.snap | 3 +- ..._tests__PLE0604_invalid_all_object.py.snap | 3 +- ..._tests__PLE0605_invalid_all_format.py.snap | 51 ++++--- ...sts__PLE0643_potential_index_error.py.snap | 3 +- ...ests__PLE0704_misplaced_bare_raise.py.snap | 13 +- ...s__PLE1141_dict_iter_missing_items.py.snap | 3 +- ...sts__PLE1205_logging_too_many_args.py.snap | 17 +-- ...ests__PLE1206_logging_too_few_args.py.snap | 9 +- ...LE1300_bad_string_format_character.py.snap | 21 ++- ...ts__PLE1307_bad_string_format_type.py.snap | 11 +- ...ests__PLE1507_invalid_envvar_value.py.snap | 5 +- ...sts__PLE1519_singledispatch_method.py.snap | 5 +- ..._tests__PLE2510_invalid_characters.py.snap | 7 +- ..._tests__PLE2513_invalid_characters.py.snap | 9 +- ...ts__PLE4703_modified_iterating_set.py.snap | 13 +- ...ts__PLR0124_comparison_with_itself.py.snap | 47 +++--- ...ts__PLR0133_comparison_of_constant.py.snap | 19 ++- ...__tests__PLR0912_too_many_branches.py.snap | 3 +- ...0917_too_many_positional_arguments.py.snap | 3 +- ...R1714_repeated_equality_comparison.py.snap | 84 +++++------ ...t__tests__PLR1722_sys_exit_alias_1.py.snap | 5 +- ...__tests__PLR1722_sys_exit_alias_11.py.snap | 3 +- ...__tests__PLR1722_sys_exit_alias_12.py.snap | 3 +- ...t__tests__PLR1722_sys_exit_alias_2.py.snap | 3 +- ...t__tests__PLR1722_sys_exit_alias_4.py.snap | 3 +- ...t__tests__PLR1722_sys_exit_alias_5.py.snap | 3 +- ...1733_unnecessary_dict_index_lookup.py.snap | 3 +- ...1736_unnecessary_list_index_lookup.py.snap | 7 +- ...ts__PLR2004_magic_value_comparison.py.snap | 17 +-- ...lint__tests__PLR2044_empty_comment.py.snap | 7 +- ...__PLR6104_non_augmented_assignment.py.snap | 35 +++-- ..._tests__PLR6201_literal_membership.py.snap | 3 +- ...pylint__tests__PLR6301_no_self_use.py.snap | 5 +- ..._tests__PLW0108_unnecessary_lambda.py.snap | 11 +- ...ests__PLW0120_useless_else_on_loop.py.snap | 3 +- ...s__PLW0127_self_assigning_variable.py.snap | 5 +- ...__PLW0128_redeclared_assigned_name.py.snap | 5 +- ...__PLW0129_assert_on_string_literal.py.snap | 3 +- ...LW0133_useless_exception_statement.py.snap | 9 +- ...W0602_global_variable_not_assigned.py.snap | 3 +- ...t__tests__PLW0603_global_statement.py.snap | 7 +- ...ts__PLW0604_global_at_module_level.py.snap | 5 +- ...ts__PLW0642_self_or_cls_assignment.py.snap | 9 +- ...lint__tests__PLW1501_bad_open_mode.py.snap | 3 +- ...ests__PLW1507_shallow_copy_environ.py.snap | 3 +- ...ts__PLW1508_invalid_envvar_default.py.snap | 3 +- ...LW1509_subprocess_popen_preexec_fn.py.snap | 3 +- ...W1510_subprocess_run_without_check.py.snap | 3 +- ...ests__PLW1514_unspecified_encoding.py.snap | 9 +- ...nt__tests__PLW1641_eq_without_hash.py.snap | 3 +- ...__tests__PLW2101_useless_with_lock.py.snap | 21 ++- ...tests__PLW2901_redefined_loop_name.py.snap | 9 +- ...ts__PLW3201_bad_dunder_method_name.py.snap | 11 +- ...int__tests__PLW3301_nested_min_max.py.snap | 13 +- ...ylint__tests__allow_magic_value_types.snap | 11 +- ...s__pylint__tests__continue_in_finally.snap | 15 +- ...r__rules__pylint__tests__max_branches.snap | 3 +- ...R1714_repeated_equality_comparison.py.snap | 84 +++++------ ...ew__PLW1508_invalid_envvar_default.py.snap | 3 +- ...ylint__tests__too_many_public_methods.snap | 22 +-- ...er__rules__pyupgrade__tests__UP001.py.snap | 3 +- ...er__rules__pyupgrade__tests__UP003.py.snap | 3 +- ...er__rules__pyupgrade__tests__UP004.py.snap | 3 +- ...__rules__pyupgrade__tests__UP009_0.py.snap | 3 +- ...__rules__pyupgrade__tests__UP009_1.py.snap | 3 +- ...er__rules__pyupgrade__tests__UP010.py.snap | 5 +- ...er__rules__pyupgrade__tests__UP013.py.snap | 22 +-- ...er__rules__pyupgrade__tests__UP014.py.snap | 10 +- ...er__rules__pyupgrade__tests__UP015.py.snap | 39 +++-- ...er__rules__pyupgrade__tests__UP018.py.snap | 5 +- ...er__rules__pyupgrade__tests__UP020.py.snap | 5 +- ...er__rules__pyupgrade__tests__UP021.py.snap | 3 +- ...er__rules__pyupgrade__tests__UP022.py.snap | 39 +++-- ...er__rules__pyupgrade__tests__UP023.py.snap | 17 +-- ...__rules__pyupgrade__tests__UP024_2.py.snap | 25 ++-- ...er__rules__pyupgrade__tests__UP025.py.snap | 39 +++-- ...__rules__pyupgrade__tests__UP032_2.py.snap | 21 ++- ...er__rules__pyupgrade__tests__UP034.py.snap | 18 +-- ...__rules__pyupgrade__tests__UP036_0.py.snap | 71 +++++---- ...__rules__pyupgrade__tests__UP036_1.py.snap | 15 +- ...__rules__pyupgrade__tests__UP036_2.py.snap | 23 ++- ...__rules__pyupgrade__tests__UP036_3.py.snap | 3 +- ...__rules__pyupgrade__tests__UP036_4.py.snap | 7 +- ...__rules__pyupgrade__tests__UP036_5.py.snap | 7 +- ...__rules__pyupgrade__tests__UP037_0.py.snap | 71 +++++---- ..._rules__pyupgrade__tests__UP037_2.pyi.snap | 3 +- ...er__rules__pyupgrade__tests__UP038.py.snap | 3 +- ...er__rules__pyupgrade__tests__UP040.py.snap | 29 ++-- ...rade__tests__datetime_utc_alias_py311.snap | 9 +- ..._annotations_keep_runtime_typing_p310.snap | 5 +- ...sts__future_annotations_pep_585_py310.snap | 5 +- ...tests__future_annotations_pep_604_p37.snap | 3 +- ...sts__future_annotations_pep_604_py310.snap | 5 +- ...es__refurb__tests__FURB105_FURB105.py.snap | 5 +- ...es__refurb__tests__FURB116_FURB116.py.snap | 13 +- ...es__refurb__tests__FURB118_FURB118.py.snap | 12 +- ...es__refurb__tests__FURB129_FURB129.py.snap | 7 +- ...es__refurb__tests__FURB131_FURB131.py.snap | 5 +- ...es__refurb__tests__FURB136_FURB136.py.snap | 35 +++-- ...es__refurb__tests__FURB140_FURB140.py.snap | 13 +- ...es__refurb__tests__FURB142_FURB142.py.snap | 37 +++-- ...es__refurb__tests__FURB145_FURB145.py.snap | 3 +- ...es__refurb__tests__FURB148_FURB148.py.snap | 47 +++--- ...es__refurb__tests__FURB152_FURB152.py.snap | 59 ++++---- ...es__refurb__tests__FURB157_FURB157.py.snap | 4 +- ...es__refurb__tests__FURB161_FURB161.py.snap | 5 +- ...es__refurb__tests__FURB163_FURB163.py.snap | 3 +- ...es__refurb__tests__FURB164_FURB164.py.snap | 3 +- ...es__refurb__tests__FURB166_FURB166.py.snap | 15 +- ...es__refurb__tests__FURB168_FURB168.py.snap | 15 +- ...es__refurb__tests__FURB169_FURB169.py.snap | 49 +++--- ...es__refurb__tests__FURB171_FURB171.py.snap | 13 +- ...es__refurb__tests__FURB177_FURB177.py.snap | 19 ++- ...es__refurb__tests__FURB180_FURB180.py.snap | 3 +- ...es__refurb__tests__FURB181_FURB181.py.snap | 16 +- ...es__refurb__tests__FURB189_FURB189.py.snap | 5 +- ...es__refurb__tests__FURB192_FURB192.py.snap | 37 +++-- ..._rules__ruff__tests__RUF005_RUF005.py.snap | 25 ++-- ..._rules__ruff__tests__RUF006_RUF006.py.snap | 5 +- ..._rules__ruff__tests__RUF010_RUF010.py.snap | 39 +++-- ..._rules__ruff__tests__RUF012_RUF012.py.snap | 6 +- ..._rules__ruff__tests__RUF015_RUF015.py.snap | 15 +- ..._rules__ruff__tests__RUF016_RUF016.py.snap | 41 +++-- ...ules__ruff__tests__RUF017_RUF017_0.py.snap | 5 +- ..._rules__ruff__tests__RUF019_RUF019.py.snap | 13 +- ..._rules__ruff__tests__RUF020_RUF020.py.snap | 6 +- ..._rules__ruff__tests__RUF021_RUF021.py.snap | 11 +- ..._rules__ruff__tests__RUF023_RUF023.py.snap | 56 +++---- ..._rules__ruff__tests__RUF024_RUF024.py.snap | 3 +- ...ules__ruff__tests__RUF027_RUF027_0.py.snap | 5 +- ..._rules__ruff__tests__RUF030_RUF030.py.snap | 36 ++--- ..._rules__ruff__tests__RUF031_RUF031.py.snap | 3 +- ..._rules__ruff__tests__RUF032_RUF032.py.snap | 43 +++--- ..._rules__ruff__tests__RUF033_RUF033.py.snap | 13 +- ..._rules__ruff__tests__RUF034_RUF034.py.snap | 5 +- ...rules__ruff__tests__RUF036_RUF036.pyi.snap | 31 ++-- ...rules__ruff__tests__RUF038_RUF038.pyi.snap | 22 +-- ..._rules__ruff__tests__RUF040_RUF040.py.snap | 3 +- ..._rules__ruff__tests__RUF041_RUF041.py.snap | 7 +- ...rules__ruff__tests__RUF041_RUF041.pyi.snap | 6 +- ..._rules__ruff__tests__RUF052_RUF052.py.snap | 4 +- ..._rules__ruff__tests__RUF056_RUF056.py.snap | 13 +- ...ules__ruff__tests__RUF101_RUF101_1.py.snap | 3 +- ...nter__rules__ruff__tests__confusables.snap | 19 ++- ...var_regexp_preset__RUF052_RUF052.py_1.snap | 4 +- ...var_regexp_preset__RUF052_RUF052.py_2.snap | 4 +- ...uff__tests__preview__RUF039_RUF039.py.snap | 8 +- ...uff__tests__preview__RUF043_RUF043.py.snap | 20 +-- ...uff__tests__preview__RUF046_RUF046.py.snap | 92 ++++++------ ...uff__tests__preview__RUF048_RUF048.py.snap | 2 +- ...f__tests__preview__RUF048_RUF048_1.py.snap | 4 +- ...uff__tests__preview__RUF049_RUF049.py.snap | 3 +- ...f__tests__preview__RUF055_RUF055_0.py.snap | 9 +- ...f__tests__preview__RUF055_RUF055_1.py.snap | 4 +- ...les__ruff__tests__preview_confusables.snap | 21 ++- ..._linter__rules__ruff__tests__ruf100_0.snap | 33 ++-- ...__rules__ruff__tests__ruf100_0_prefix.snap | 31 ++-- ..._linter__rules__ruff__tests__ruf100_3.snap | 9 +- ..._linter__rules__ruff__tests__ruf100_5.snap | 7 +- ..._error-instead-of-exception_TRY400.py.snap | 11 +- ..._tests__raise-vanilla-class_TRY002.py.snap | 5 +- ...ps__tests__raise-within-try_TRY301.py.snap | 13 +- ..._tests__verbose-log-message_TRY401.py.snap | 5 +- ...er__linter__tests__ipy_escape_command.snap | 5 +- ...er__linter__tests__vscode_language_id.snap | 3 +- ...essions__arguments__double_starred.py.snap | 7 +- ...ons__arguments__invalid_expression.py.snap | 5 +- ...ons__arguments__missing_expression.py.snap | 3 +- ...expressions__arguments__unclosed_0.py.snap | 3 +- ...expressions__arguments__unclosed_1.py.snap | 3 +- ...expressions__arguments__unclosed_2.py.snap | 3 +- ...xpressions__await__no_expression_0.py.snap | 3 +- ...xpressions__await__no_expression_1.py.snap | 3 +- ...syntax@expressions__await__recover.py.snap | 5 +- ...ns__bin_op__invalid_rhs_expression.py.snap | 5 +- ...x@expressions__bin_op__missing_lhs.py.snap | 3 +- ...expressions__bin_op__missing_rhs_0.py.snap | 3 +- ...expressions__bin_op__missing_rhs_1.py.snap | 3 +- ...s__bool_op__invalid_rhs_expression.py.snap | 5 +- ...@expressions__bool_op__missing_rhs.py.snap | 3 +- ...xpressions__compare__invalid_order.py.snap | 5 +- ...s__compare__invalid_rhs_expression.py.snap | 5 +- ...@expressions__compare__missing_lhs.py.snap | 3 +- ...xpressions__compare__missing_rhs_0.py.snap | 3 +- ...xpressions__compare__missing_rhs_1.py.snap | 5 +- ...xpressions__compare__missing_rhs_2.py.snap | 3 +- ...sions__compare__starred_expression.py.snap | 5 +- ...x@expressions__dict__comprehension.py.snap | 5 +- ...tax@expressions__dict__double_star.py.snap | 5 +- ...s__dict__double_star_comprehension.py.snap | 21 ++- ...ons__dict__missing_closing_brace_2.py.snap | 3 +- ...ressions__dict__named_expression_0.py.snap | 9 +- ...ressions__dict__named_expression_1.py.snap | 17 +-- ..._syntax@expressions__dict__recover.py.snap | 19 ++- ...tax@expressions__emoji_identifiers.py.snap | 7 +- ...essions__if__missing_orelse_expr_0.py.snap | 3 +- ...essions__if__missing_orelse_expr_1.py.snap | 3 +- ...pressions__if__missing_test_expr_0.py.snap | 3 +- ...pressions__if__missing_test_expr_1.py.snap | 3 +- ...id_syntax@expressions__if__recover.py.snap | 3 +- ...sions__lambda_duplicate_parameters.py.snap | 19 ++- ...x@expressions__list__comprehension.py.snap | 7 +- ...s__list__missing_closing_bracket_3.py.snap | 5 +- ..._syntax@expressions__list__recover.py.snap | 25 ++-- ...__list__star_expression_precedence.py.snap | 3 +- ...expressions__named__invalid_target.py.snap | 3 +- ...sions__named__missing_expression_4.py.snap | 5 +- ...nthesized__missing_closing_paren_3.py.snap | 5 +- ...ions__parenthesized__parenthesized.py.snap | 3 +- ...@expressions__parenthesized__tuple.py.snap | 41 +++-- ..._parenthesized__tuple_starred_expr.py.snap | 5 +- ...ax@expressions__set__comprehension.py.snap | 7 +- ...set__missing_closing_curly_brace_3.py.snap | 5 +- ...d_syntax@expressions__set__recover.py.snap | 23 ++- ...s__set__star_expression_precedence.py.snap | 3 +- ...__subscript__invalid_slice_element.py.snap | 7 +- ...xpressions__unary__no_expression_0.py.snap | 3 +- ...xpressions__unary__no_expression_1.py.snap | 3 +- ...pressions__yield__named_expression.py.snap | 5 +- ...xpressions__yield__star_expression.py.snap | 5 +- ...ns__yield_from__starred_expression.py.snap | 3 +- ...sions__yield_from__unparenthesized.py.snap | 5 +- ...tax@re_lexing__line_continuation_1.py.snap | 7 +- ...atements__function_type_parameters.py.snap | 29 ++-- ...ements__invalid_assignment_targets.py.snap | 21 ++- ...nvalid_augmented_assignment_target.py.snap | 11 +- ...s__with__ambiguous_lpar_with_items.py.snap | 29 ++-- ...statements__with__empty_with_items.py.snap | 5 +- ...__with__unparenthesized_with_items.py.snap | 3 +- 773 files changed, 3603 insertions(+), 4313 deletions(-) diff --git a/crates/ruff/tests/integration_test.rs b/crates/ruff/tests/integration_test.rs index bae45dd22f78a..c9f1a674597c3 100644 --- a/crates/ruff/tests/integration_test.rs +++ b/crates/ruff/tests/integration_test.rs @@ -623,7 +623,7 @@ fn stdin_override_parser_py() { fn stdin_fix_when_not_fixable_should_still_print_contents() { let mut cmd = RuffCheck::default().args(["--fix"]).build(); assert_cmd_snapshot!(cmd - .pass_stdin("import os\nimport sys\n\nif (1, 2):\n print(sys.version)\n"), @r" + .pass_stdin("import os\nimport sys\n\nif (1, 2):\n print(sys.version)\n"), @r###" success: false exit_code: 1 ----- stdout ----- @@ -636,14 +636,14 @@ fn stdin_fix_when_not_fixable_should_still_print_contents() { -:3:4: F634 If test is a tuple, which is always `True` | 1 | import sys - 2 | + 2 | 3 | if (1, 2): | ^^^^^^ F634 4 | print(sys.version) | Found 2 errors (1 fixed, 1 remaining). - "); + "###); } #[test] diff --git a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__notebook_output.snap b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__notebook_output.snap index af1c20d90cd39..3d8a6d9c4b881 100644 --- a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__notebook_output.snap +++ b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__notebook_output.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_linter/src/message/text.rs expression: content -snapshot_kind: text --- notebook.ipynb:cell 1:2:8: F401 [*] `os` imported but unused | @@ -16,7 +15,7 @@ notebook.ipynb:cell 2:2:8: F401 [*] `math` imported but unused 1 | # cell 2 2 | import math | ^^^^ F401 -3 | +3 | 4 | print('hello world') | = help: Remove unused import: `math` diff --git a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__syntax_errors.snap b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__syntax_errors.snap index 2595f4eaa7cb0..b0cb4085807d0 100644 --- a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__syntax_errors.snap +++ b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__syntax_errors.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/message/text.rs expression: content -snapshot_kind: text --- syntax_errors.py:1:15: SyntaxError: Expected one or more symbol names after import | 1 | from os import | ^ -2 | +2 | 3 | if call(foo 4 | def bar(): | @@ -15,7 +14,7 @@ syntax_errors.py:1:15: SyntaxError: Expected one or more symbol names after impo syntax_errors.py:3:12: SyntaxError: Expected ')', found newline | 1 | from os import -2 | +2 | 3 | if call(foo | ^ 4 | def bar(): diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR001_AIR001.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR001_AIR001.py.snap index 1da4d56d20539..c2ed187615c33 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR001_AIR001.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR001_AIR001.py.snap @@ -6,7 +6,7 @@ AIR001.py:11:1: AIR001 Task variable name should match the `task_id`: "my_task" 10 | my_task = PythonOperator(task_id="my_task", callable=my_callable) 11 | incorrect_name = PythonOperator(task_id="my_task") # AIR001 | ^^^^^^^^^^^^^^ AIR001 -12 | +12 | 13 | my_task = AirbyteTriggerSyncOperator(task_id="my_task", callable=my_callable) | @@ -15,7 +15,7 @@ AIR001.py:14:1: AIR001 Task variable name should match the `task_id`: "my_task" 13 | my_task = AirbyteTriggerSyncOperator(task_id="my_task", callable=my_callable) 14 | incorrect_name = AirbyteTriggerSyncOperator(task_id="my_task") # AIR001 | ^^^^^^^^^^^^^^ AIR001 -15 | +15 | 16 | my_task = AppflowFlowRunOperator(task_id="my_task", callable=my_callable) | @@ -24,6 +24,6 @@ AIR001.py:17:1: AIR001 Task variable name should match the `task_id`: "my_task" 16 | my_task = AppflowFlowRunOperator(task_id="my_task", callable=my_callable) 17 | incorrect_name = AppflowFlowRunOperator(task_id="my_task") # AIR001 | ^^^^^^^^^^^^^^ AIR001 -18 | +18 | 19 | # Consider only from the `airflow.operators` (or providers operators) module | diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301.py.snap index d25605ac55561..6407aa9ab2c3f 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301.py.snap @@ -4,10 +4,10 @@ source: crates/ruff_linter/src/rules/airflow/mod.rs AIR301.py:4:1: AIR301 DAG should have an explicit `schedule` argument | 2 | from airflow.timetables.simple import NullTimetable -3 | +3 | 4 | DAG(dag_id="class_default_schedule") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR301 -5 | +5 | 6 | DAG(dag_id="class_schedule", schedule="@hourly") | diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_args.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_args.py.snap index 1f9f4a94f2ad7..77cd842f09955 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_args.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_args.py.snap @@ -4,10 +4,10 @@ source: crates/ruff_linter/src/rules/airflow/mod.rs AIR302_args.py:18:39: AIR302 [*] `schedule_interval` is removed in Airflow 3.0 | 16 | DAG(dag_id="class_schedule", schedule="@hourly") -17 | +17 | 18 | DAG(dag_id="class_schedule_interval", schedule_interval="@hourly") | ^^^^^^^^^^^^^^^^^ AIR302 -19 | +19 | 20 | DAG(dag_id="class_timetable", timetable=NullTimetable()) | = help: Use `schedule` instead @@ -25,7 +25,7 @@ AIR302_args.py:18:39: AIR302 [*] `schedule_interval` is removed in Airflow 3.0 AIR302_args.py:20:31: AIR302 [*] `timetable` is removed in Airflow 3.0 | 18 | DAG(dag_id="class_schedule_interval", schedule_interval="@hourly") -19 | +19 | 20 | DAG(dag_id="class_timetable", timetable=NullTimetable()) | ^^^^^^^^^ AIR302 | @@ -238,14 +238,14 @@ AIR302_args.py:90:16: AIR302 `filename_template` is removed in Airflow 3.0 89 | ElasticsearchTaskHandler(filename_template="/tmp/test") 90 | GCSTaskHandler(filename_template="/tmp/test") | ^^^^^^^^^^^^^^^^^ AIR302 -91 | +91 | 92 | FabAuthManager(None) | AIR302_args.py:92:15: AIR302 `appbuilder` is removed in Airflow 3.0; The constructor takes no parameter now | 90 | GCSTaskHandler(filename_template="/tmp/test") -91 | +91 | 92 | FabAuthManager(None) | ^^^^^^ AIR302 | diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_class_attribute.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_class_attribute.py.snap index 4066c8e63d673..bdea27dfc9b5f 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_class_attribute.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_class_attribute.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs -snapshot_kind: text --- AIR302_class_attribute.py:13:4: AIR302 `register_dataset_change` is removed in Airflow 3.0 | @@ -50,7 +49,7 @@ AIR302_class_attribute.py:17:4: AIR302 `notify_dataset_alias_created` is removed 16 | dm.notify_dataset_changed() 17 | dm.notify_dataset_alias_created() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 -18 | +18 | 19 | hlc = HookLineageCollector() | = help: Use `notify_asset_alias_created` instead @@ -92,7 +91,7 @@ AIR302_class_attribute.py:23:5: AIR302 `collected_datasets` is removed in Airflo 22 | hlc.add_output_dataset() 23 | hlc.collected_datasets() | ^^^^^^^^^^^^^^^^^^ AIR302 -24 | +24 | 25 | aam = AwsAuthManager() | = help: Use `collected_assets` instead @@ -102,7 +101,7 @@ AIR302_class_attribute.py:26:5: AIR302 `is_authorized_dataset` is removed in Air 25 | aam = AwsAuthManager() 26 | aam.is_authorized_dataset() | ^^^^^^^^^^^^^^^^^^^^^ AIR302 -27 | +27 | 28 | pm = ProvidersManager() | = help: Use `is_authorized_asset` instead @@ -113,7 +112,7 @@ AIR302_class_attribute.py:30:4: AIR302 `dataset_factories` is removed in Airflow 29 | pm.initialize_providers_asset_uri_resources() 30 | pm.dataset_factories | ^^^^^^^^^^^^^^^^^ AIR302 -31 | +31 | 32 | base_secret_backend = BaseSecretsBackend() | = help: Use `asset_factories` instead @@ -133,7 +132,7 @@ AIR302_class_attribute.py:34:21: AIR302 `get_connections` is removed in Airflow 33 | base_secret_backend.get_conn_uri() 34 | base_secret_backend.get_connections() | ^^^^^^^^^^^^^^^ AIR302 -35 | +35 | 36 | csm_backend = CloudSecretManagerBackend() | = help: Use `get_connection` instead @@ -153,7 +152,7 @@ AIR302_class_attribute.py:38:13: AIR302 `get_connections` is removed in Airflow 37 | csm_backend.get_conn_uri() 38 | csm_backend.get_connections() | ^^^^^^^^^^^^^^^ AIR302 -39 | +39 | 40 | vault_backend = VaultBackend() | = help: Use `get_connection` instead @@ -173,7 +172,7 @@ AIR302_class_attribute.py:42:15: AIR302 `get_connections` is removed in Airflow 41 | vault_backend.get_conn_uri() 42 | vault_backend.get_connections() | ^^^^^^^^^^^^^^^ AIR302 -43 | +43 | 44 | not_an_error = NotAir302SecretError() | = help: Use `get_connection` instead @@ -204,7 +203,7 @@ AIR302_class_attribute.py:56:18: AIR302 `dataset_to_openlineage_converters` is r 55 | provider_manager.dataset_uri_handlers 56 | provider_manager.dataset_to_openlineage_converters | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 -57 | +57 | 58 | dl_info = DatasetLineageInfo() | = help: Use `asset_to_openlineage_converters` instead @@ -212,7 +211,7 @@ AIR302_class_attribute.py:56:18: AIR302 `dataset_to_openlineage_converters` is r AIR302_class_attribute.py:58:11: AIR302 `airflow.lineage.hook.DatasetLineageInfo` is removed in Airflow 3.0 | 56 | provider_manager.dataset_to_openlineage_converters -57 | +57 | 58 | dl_info = DatasetLineageInfo() | ^^^^^^^^^^^^^^^^^^ AIR302 59 | dl_info.dataset diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_names.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_names.py.snap index 03104f2eeecda..75763389280a8 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_names.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_names.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs -snapshot_kind: text --- AIR302_names.py:105:1: AIR302 `airflow.PY36` is removed in Airflow 3.0 | @@ -71,7 +70,7 @@ AIR302_names.py:106:1: AIR302 `airflow.Dataset` is removed in Airflow 3.0 105 | PY36, PY37, PY38, PY39, PY310, PY311, PY312 106 | DatasetFromRoot() | ^^^^^^^^^^^^^^^ AIR302 -107 | +107 | 108 | dataset_from_root = DatasetFromRoot() | = help: Use `airflow.sdk.definitions.asset.Asset` instead @@ -79,7 +78,7 @@ AIR302_names.py:106:1: AIR302 `airflow.Dataset` is removed in Airflow 3.0 AIR302_names.py:108:21: AIR302 `airflow.Dataset` is removed in Airflow 3.0 | 106 | DatasetFromRoot() -107 | +107 | 108 | dataset_from_root = DatasetFromRoot() | ^^^^^^^^^^^^^^^ AIR302 109 | dataset_from_root.iter_datasets() @@ -102,7 +101,7 @@ AIR302_names.py:110:19: AIR302 `iter_dataset_aliases` is removed in Airflow 3.0 109 | dataset_from_root.iter_datasets() 110 | dataset_from_root.iter_dataset_aliases() | ^^^^^^^^^^^^^^^^^^^^ AIR302 -111 | +111 | 112 | # airflow.api_connexion.security | = help: Use `iter_asset_aliases` instead @@ -112,7 +111,7 @@ AIR302_names.py:113:1: AIR302 `airflow.api_connexion.security.requires_access` i 112 | # airflow.api_connexion.security 113 | requires_access, requires_access_dataset | ^^^^^^^^^^^^^^^ AIR302 -114 | +114 | 115 | # airflow.auth.managers | = help: Use `airflow.api_connexion.security.requires_access_*` instead @@ -122,7 +121,7 @@ AIR302_names.py:113:18: AIR302 `airflow.api_connexion.security.requires_access_d 112 | # airflow.api_connexion.security 113 | requires_access, requires_access_dataset | ^^^^^^^^^^^^^^^^^^^^^^^ AIR302 -114 | +114 | 115 | # airflow.auth.managers | = help: Use `airflow.api_connexion.security.requires_access_asset` instead @@ -142,7 +141,7 @@ AIR302_names.py:117:1: AIR302 `airflow.auth.managers.models.resource_details.Dat 116 | is_authorized_dataset 117 | DatasetDetails() | ^^^^^^^^^^^^^^ AIR302 -118 | +118 | 119 | # airflow.configuration | = help: Use `airflow.auth.managers.models.resource_details.AssetDetails` instead @@ -216,7 +215,7 @@ AIR302_names.py:124:1: AIR302 `airflow.contrib.aws_athena_hook.AWSAthenaHook` is 123 | # airflow.contrib.* 124 | AWSAthenaHook() | ^^^^^^^^^^^^^ AIR302 -125 | +125 | 126 | # airflow.datasets | @@ -289,7 +288,7 @@ AIR302_names.py:133:1: AIR302 `airflow.datasets.metadata.Metadata` is removed in 132 | expand_alias_to_datasets 133 | Metadata() | ^^^^^^^^ AIR302 -134 | +134 | 135 | dataset_to_test_method_call = Dataset() | = help: Use `airflow.sdk.definitions.asset.metadata.Metadata` instead @@ -297,7 +296,7 @@ AIR302_names.py:133:1: AIR302 `airflow.datasets.metadata.Metadata` is removed in AIR302_names.py:135:31: AIR302 `airflow.datasets.Dataset` is removed in Airflow 3.0 | 133 | Metadata() -134 | +134 | 135 | dataset_to_test_method_call = Dataset() | ^^^^^^^ AIR302 136 | dataset_to_test_method_call.iter_datasets() @@ -320,7 +319,7 @@ AIR302_names.py:137:29: AIR302 `iter_dataset_aliases` is removed in Airflow 3.0 136 | dataset_to_test_method_call.iter_datasets() 137 | dataset_to_test_method_call.iter_dataset_aliases() | ^^^^^^^^^^^^^^^^^^^^ AIR302 -138 | +138 | 139 | alias_to_test_method_call = DatasetAlias() | = help: Use `iter_asset_aliases` instead @@ -328,7 +327,7 @@ AIR302_names.py:137:29: AIR302 `iter_dataset_aliases` is removed in Airflow 3.0 AIR302_names.py:139:29: AIR302 `airflow.datasets.DatasetAlias` is removed in Airflow 3.0 | 137 | dataset_to_test_method_call.iter_dataset_aliases() -138 | +138 | 139 | alias_to_test_method_call = DatasetAlias() | ^^^^^^^^^^^^ AIR302 140 | alias_to_test_method_call.iter_datasets() @@ -351,7 +350,7 @@ AIR302_names.py:141:27: AIR302 `iter_dataset_aliases` is removed in Airflow 3.0 140 | alias_to_test_method_call.iter_datasets() 141 | alias_to_test_method_call.iter_dataset_aliases() | ^^^^^^^^^^^^^^^^^^^^ AIR302 -142 | +142 | 143 | any_to_test_method_call = DatasetAny() | = help: Use `iter_asset_aliases` instead @@ -359,7 +358,7 @@ AIR302_names.py:141:27: AIR302 `iter_dataset_aliases` is removed in Airflow 3.0 AIR302_names.py:143:27: AIR302 `airflow.datasets.DatasetAny` is removed in Airflow 3.0 | 141 | alias_to_test_method_call.iter_dataset_aliases() -142 | +142 | 143 | any_to_test_method_call = DatasetAny() | ^^^^^^^^^^ AIR302 144 | any_to_test_method_call.iter_datasets() @@ -382,7 +381,7 @@ AIR302_names.py:145:25: AIR302 `iter_dataset_aliases` is removed in Airflow 3.0 144 | any_to_test_method_call.iter_datasets() 145 | any_to_test_method_call.iter_dataset_aliases() | ^^^^^^^^^^^^^^^^^^^^ AIR302 -146 | +146 | 147 | # airflow.datasets.manager | = help: Use `iter_asset_aliases` instead @@ -392,7 +391,7 @@ AIR302_names.py:148:19: AIR302 `airflow.datasets.manager.dataset_manager` is rem 147 | # airflow.datasets.manager 148 | DatasetManager(), dataset_manager, resolve_dataset_manager | ^^^^^^^^^^^^^^^ AIR302 -149 | +149 | 150 | # airflow.hooks | = help: Use `airflow.assets.manager` instead @@ -402,7 +401,7 @@ AIR302_names.py:148:36: AIR302 `airflow.datasets.manager.resolve_dataset_manager 147 | # airflow.datasets.manager 148 | DatasetManager(), dataset_manager, resolve_dataset_manager | ^^^^^^^^^^^^^^^^^^^^^^^ AIR302 -149 | +149 | 150 | # airflow.hooks | = help: Use `airflow.assets.resolve_asset_manager` instead @@ -412,7 +411,7 @@ AIR302_names.py:151:1: AIR302 `airflow.hooks.base_hook.BaseHook` is removed in A 150 | # airflow.hooks 151 | BaseHook() | ^^^^^^^^ AIR302 -152 | +152 | 153 | # airflow.lineage.hook | = help: Use `airflow.hooks.base.BaseHook` instead @@ -422,7 +421,7 @@ AIR302_names.py:154:1: AIR302 `airflow.lineage.hook.DatasetLineageInfo` is remov 153 | # airflow.lineage.hook 154 | DatasetLineageInfo() | ^^^^^^^^^^^^^^^^^^ AIR302 -155 | +155 | 156 | # airflow.listeners.spec.dataset | = help: Use `airflow.lineage.hook.AssetLineageInfo` instead @@ -432,7 +431,7 @@ AIR302_names.py:157:1: AIR302 `airflow.listeners.spec.dataset.on_dataset_changed 156 | # airflow.listeners.spec.dataset 157 | on_dataset_changed, on_dataset_created | ^^^^^^^^^^^^^^^^^^ AIR302 -158 | +158 | 159 | # airflow.metrics.validators | = help: Use `airflow.listeners.spec.asset.on_asset_changed` instead @@ -442,7 +441,7 @@ AIR302_names.py:157:21: AIR302 `airflow.listeners.spec.dataset.on_dataset_create 156 | # airflow.listeners.spec.dataset 157 | on_dataset_changed, on_dataset_created | ^^^^^^^^^^^^^^^^^^ AIR302 -158 | +158 | 159 | # airflow.metrics.validators | = help: Use `airflow.listeners.spec.asset.on_asset_created` instead @@ -452,7 +451,7 @@ AIR302_names.py:160:1: AIR302 `airflow.metrics.validators.AllowListValidator` is 159 | # airflow.metrics.validators 160 | AllowListValidator(), BlockListValidator() | ^^^^^^^^^^^^^^^^^^ AIR302 -161 | +161 | 162 | # airflow.operators.dummy_operator | = help: Use `airflow.metrics.validators.PatternAllowListValidator` instead @@ -462,7 +461,7 @@ AIR302_names.py:160:23: AIR302 `airflow.metrics.validators.BlockListValidator` i 159 | # airflow.metrics.validators 160 | AllowListValidator(), BlockListValidator() | ^^^^^^^^^^^^^^^^^^ AIR302 -161 | +161 | 162 | # airflow.operators.dummy_operator | = help: Use `airflow.metrics.validators.PatternBlockListValidator` instead @@ -482,7 +481,7 @@ AIR302_names.py:164:16: AIR302 `airflow.operators.dummy_operator.DummyOperator` 163 | dummy_operator.EmptyOperator() 164 | dummy_operator.DummyOperator() | ^^^^^^^^^^^^^ AIR302 -165 | +165 | 166 | # airflow.operators.bash_operator | = help: Use `airflow.operators.empty.EmptyOperator` instead @@ -492,7 +491,7 @@ AIR302_names.py:167:1: AIR302 `airflow.operators.bash_operator.BashOperator` is 166 | # airflow.operators.bash_operator 167 | BashOperator() | ^^^^^^^^^^^^ AIR302 -168 | +168 | 169 | # airflow.operators.branch_operator | = help: Use `airflow.operators.bash.BashOperator` instead @@ -502,7 +501,7 @@ AIR302_names.py:170:1: AIR302 `airflow.operators.branch_operator.BaseBranchOpera 169 | # airflow.operators.branch_operator 170 | BaseBranchOperator() | ^^^^^^^^^^^^^^^^^^ AIR302 -171 | +171 | 172 | # airflow.operators.dagrun_operator | = help: Use `airflow.operators.branch.BaseBranchOperator` instead @@ -522,7 +521,7 @@ AIR302_names.py:174:1: AIR302 `airflow.operators.dagrun_operator.TriggerDagRunOp 173 | TriggerDagRunLink() 174 | TriggerDagRunOperator() | ^^^^^^^^^^^^^^^^^^^^^ AIR302 -175 | +175 | 176 | # airflow.operators.dummy | = help: Use `airflow.operators.trigger_dagrun.TriggerDagRunOperator` instead @@ -532,7 +531,7 @@ AIR302_names.py:177:18: AIR302 `airflow.operators.dummy.DummyOperator` is remove 176 | # airflow.operators.dummy 177 | EmptyOperator(), DummyOperator() | ^^^^^^^^^^^^^ AIR302 -178 | +178 | 179 | # airflow.operators.email_operator | = help: Use `airflow.operators.empty.EmptyOperator` instead @@ -542,7 +541,7 @@ AIR302_names.py:180:1: AIR302 `airflow.operators.email_operator.EmailOperator` i 179 | # airflow.operators.email_operator 180 | EmailOperator() | ^^^^^^^^^^^^^ AIR302 -181 | +181 | 182 | # airflow.operators.latest_only_operator | = help: Use `airflow.operators.email.EmailOperator` instead @@ -552,7 +551,7 @@ AIR302_names.py:183:1: AIR302 `airflow.operators.latest_only_operator.LatestOnly 182 | # airflow.operators.latest_only_operator 183 | LatestOnlyOperator() | ^^^^^^^^^^^^^^^^^^ AIR302 -184 | +184 | 185 | # airflow.operators.python_operator | = help: Use `airflow.operators.latest_only.LatestOnlyOperator` instead @@ -594,7 +593,7 @@ AIR302_names.py:189:1: AIR302 `airflow.operators.python_operator.ShortCircuitOpe 188 | PythonVirtualenvOperator() 189 | ShortCircuitOperator() | ^^^^^^^^^^^^^^^^^^^^ AIR302 -190 | +190 | 191 | # airflow.operators.subdag.* | = help: Use `airflow.operators.python.ShortCircuitOperator` instead @@ -604,7 +603,7 @@ AIR302_names.py:192:1: AIR302 `airflow.operators.subdag.SubDagOperator` is remov 191 | # airflow.operators.subdag.* 192 | SubDagOperator() | ^^^^^^^^^^^^^^ AIR302 -193 | +193 | 194 | # airflow.providers.amazon | @@ -645,7 +644,7 @@ AIR302_names.py:198:4: AIR302 `airflow.providers.amazon.aws.datasets.s3.sanitize 197 | s3.convert_dataset_to_openlineage 198 | s3.sanitize_uri | ^^^^^^^^^^^^ AIR302 -199 | +199 | 200 | # airflow.providers.common.io | = help: Use `airflow.providers.amazon.aws.assets.s3.sanitize_uri` instead @@ -676,7 +675,7 @@ AIR302_names.py:203:16: AIR302 `airflow.providers.common.io.datasets.file.saniti 202 | common_io_file.create_dataset 203 | common_io_file.sanitize_uri | ^^^^^^^^^^^^ AIR302 -204 | +204 | 205 | # airflow.providers.fab | = help: Use `airflow.providers.common.io.assets.file.sanitize_uri` instead @@ -686,7 +685,7 @@ AIR302_names.py:206:18: AIR302 `airflow.providers.fab.auth_manager.fab_auth_mana 205 | # airflow.providers.fab 206 | fab_auth_manager.is_authorized_dataset | ^^^^^^^^^^^^^^^^^^^^^ AIR302 -207 | +207 | 208 | # airflow.providers.google | = help: Use `airflow.providers.fab.auth_manager.fab_auth_manager.is_authorized_asset` instead @@ -694,7 +693,7 @@ AIR302_names.py:206:18: AIR302 `airflow.providers.fab.auth_manager.fab_auth_mana AIR302_names.py:211:5: AIR302 `airflow.providers.google.datasets.gcs.create_dataset` is removed in Airflow 3.0 | 209 | bigquery.sanitize_uri -210 | +210 | 211 | gcs.create_dataset | ^^^^^^^^^^^^^^ AIR302 212 | gcs.sanitize_uri @@ -717,7 +716,7 @@ AIR302_names.py:213:5: AIR302 `airflow.providers.google.datasets.gcs.convert_dat 212 | gcs.sanitize_uri 213 | gcs.convert_dataset_to_openlineage | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 -214 | +214 | 215 | # airflow.providers.mysql | = help: Use `airflow.providers.google.assets.gcs.convert_asset_to_openlineage` instead @@ -727,7 +726,7 @@ AIR302_names.py:216:7: AIR302 `airflow.providers.mysql.datasets.mysql.sanitize_u 215 | # airflow.providers.mysql 216 | mysql.sanitize_uri | ^^^^^^^^^^^^ AIR302 -217 | +217 | 218 | # airflow.providers.openlineage | = help: Use `airflow.providers.mysql.assets.mysql.sanitize_uri` instead @@ -737,7 +736,7 @@ AIR302_names.py:219:1: AIR302 `airflow.providers.openlineage.utils.utils.Dataset 218 | # airflow.providers.openlineage 219 | DatasetInfo(), translate_airflow_dataset | ^^^^^^^^^^^ AIR302 -220 | +220 | 221 | # airflow.providers.postgres | = help: Use `airflow.providers.openlineage.utils.utils.AssetInfo` instead @@ -747,7 +746,7 @@ AIR302_names.py:219:16: AIR302 `airflow.providers.openlineage.utils.utils.transl 218 | # airflow.providers.openlineage 219 | DatasetInfo(), translate_airflow_dataset | ^^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 -220 | +220 | 221 | # airflow.providers.postgres | = help: Use `airflow.providers.openlineage.utils.utils.translate_airflow_asset` instead @@ -757,7 +756,7 @@ AIR302_names.py:222:10: AIR302 `airflow.providers.postgres.datasets.postgres.san 221 | # airflow.providers.postgres 222 | postgres.sanitize_uri | ^^^^^^^^^^^^ AIR302 -223 | +223 | 224 | # airflow.providers.trino | = help: Use `airflow.providers.postgres.assets.postgres.sanitize_uri` instead @@ -767,7 +766,7 @@ AIR302_names.py:225:7: AIR302 `airflow.providers.trino.datasets.trino.sanitize_u 224 | # airflow.providers.trino 225 | trino.sanitize_uri | ^^^^^^^^^^^^ AIR302 -226 | +226 | 227 | # airflow.secrets | = help: Use `airflow.providers.trino.assets.trino.sanitize_uri` instead @@ -777,7 +776,7 @@ AIR302_names.py:228:1: AIR302 `airflow.secrets.local_filesystem.get_connection` 227 | # airflow.secrets 228 | get_connection, load_connections | ^^^^^^^^^^^^^^ AIR302 -229 | +229 | 230 | # airflow.security.permissions | = help: Use `airflow.secrets.local_filesystem.load_connections_dict` instead @@ -787,7 +786,7 @@ AIR302_names.py:228:17: AIR302 `airflow.secrets.local_filesystem.load_connection 227 | # airflow.secrets 228 | get_connection, load_connections | ^^^^^^^^^^^^^^^^ AIR302 -229 | +229 | 230 | # airflow.security.permissions | = help: Use `airflow.secrets.local_filesystem.load_connections_dict` instead @@ -797,7 +796,7 @@ AIR302_names.py:231:1: AIR302 `airflow.security.permissions.RESOURCE_DATASET` is 230 | # airflow.security.permissions 231 | RESOURCE_DATASET | ^^^^^^^^^^^^^^^^ AIR302 -232 | +232 | 233 | # airflow.sensors.base_sensor_operator | = help: Use `airflow.security.permissions.RESOURCE_ASSET` instead @@ -807,7 +806,7 @@ AIR302_names.py:234:1: AIR302 `airflow.sensors.base_sensor_operator.BaseSensorOp 233 | # airflow.sensors.base_sensor_operator 234 | BaseSensorOperator() | ^^^^^^^^^^^^^^^^^^ AIR302 -235 | +235 | 236 | # airflow.sensors.date_time_sensor | = help: Use `airflow.sensors.base.BaseSensorOperator` instead @@ -817,7 +816,7 @@ AIR302_names.py:237:1: AIR302 `airflow.sensors.date_time_sensor.DateTimeSensor` 236 | # airflow.sensors.date_time_sensor 237 | DateTimeSensor() | ^^^^^^^^^^^^^^ AIR302 -238 | +238 | 239 | # airflow.sensors.external_task | = help: Use `airflow.sensors.date_time.DateTimeSensor` instead @@ -827,7 +826,7 @@ AIR302_names.py:240:1: AIR302 `airflow.sensors.external_task.ExternalTaskSensorL 239 | # airflow.sensors.external_task 240 | ExternalTaskSensorLinkFromExternalTask() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 -241 | +241 | 242 | # airflow.sensors.external_task_sensor | = help: Use `airflow.sensors.external_task.ExternalDagLink` instead @@ -858,7 +857,7 @@ AIR302_names.py:245:1: AIR302 `airflow.sensors.external_task_sensor.ExternalTask 244 | ExternalTaskSensor() 245 | ExternalTaskSensorLinkFromExternalTaskSensor() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 -246 | +246 | 247 | # airflow.sensors.time_delta_sensor | = help: Use `airflow.sensors.external_task.ExternalDagLink` instead @@ -868,7 +867,7 @@ AIR302_names.py:248:1: AIR302 `airflow.sensors.time_delta_sensor.TimeDeltaSensor 247 | # airflow.sensors.time_delta_sensor 248 | TimeDeltaSensor() | ^^^^^^^^^^^^^^^ AIR302 -249 | +249 | 250 | # airflow.timetables | = help: Use `airflow.sensors.time_delta.TimeDeltaSensor` instead @@ -888,7 +887,7 @@ AIR302_names.py:252:1: AIR302 `airflow.timetables.simple.DatasetTriggeredTimetab 251 | DatasetOrTimeSchedule() 252 | DatasetTriggeredTimetable() | ^^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 -253 | +253 | 254 | # airflow.triggers.external_task | = help: Use `airflow.timetables.simple.AssetTriggeredTimetable` instead @@ -898,7 +897,7 @@ AIR302_names.py:255:1: AIR302 `airflow.triggers.external_task.TaskStateTrigger` 254 | # airflow.triggers.external_task 255 | TaskStateTrigger() | ^^^^^^^^^^^^^^^^ AIR302 -256 | +256 | 257 | # airflow.utils.date | @@ -917,7 +916,7 @@ AIR302_names.py:259:7: AIR302 `airflow.utils.dates.days_ago` is removed in Airfl 258 | dates.date_range 259 | dates.days_ago | ^^^^^^^^ AIR302 -260 | +260 | 261 | date_range | = help: Use `pendulum.today('UTC').add(days=-N, ...)` instead @@ -925,7 +924,7 @@ AIR302_names.py:259:7: AIR302 `airflow.utils.dates.days_ago` is removed in Airfl AIR302_names.py:261:1: AIR302 `airflow.utils.dates.date_range` is removed in Airflow 3.0 | 259 | dates.days_ago -260 | +260 | 261 | date_range | ^^^^^^^^^^ AIR302 262 | days_ago @@ -978,7 +977,7 @@ AIR302_names.py:266:1: AIR302 `airflow.utils.dates.scale_time_units` is removed 265 | round_time 266 | scale_time_units | ^^^^^^^^^^^^^^^^ AIR302 -267 | +267 | 268 | # This one was not deprecated. | @@ -987,7 +986,7 @@ AIR302_names.py:273:1: AIR302 `airflow.utils.dag_cycle_tester.test_cycle` is rem 272 | # airflow.utils.dag_cycle_tester 273 | test_cycle | ^^^^^^^^^^ AIR302 -274 | +274 | 275 | # airflow.utils.decorators | @@ -996,7 +995,7 @@ AIR302_names.py:276:1: AIR302 `airflow.utils.decorators.apply_defaults` is remov 275 | # airflow.utils.decorators 276 | apply_defaults | ^^^^^^^^^^^^^^ AIR302 -277 | +277 | 278 | # airflow.utils.file | @@ -1005,7 +1004,7 @@ AIR302_names.py:279:22: AIR302 `airflow.utils.file.mkdirs` is removed in Airflow 278 | # airflow.utils.file 279 | TemporaryDirector(), mkdirs | ^^^^^^ AIR302 -280 | +280 | 281 | # airflow.utils.helpers | = help: Use `pendulum.today('UTC').add(days=-N, ...)` instead @@ -1015,7 +1014,7 @@ AIR302_names.py:282:1: AIR302 `airflow.utils.helpers.chain` is removed in Airflo 281 | # airflow.utils.helpers 282 | chain, cross_downstream | ^^^^^ AIR302 -283 | +283 | 284 | # airflow.utils.state | = help: Use `airflow.models.baseoperator.chain` instead @@ -1025,7 +1024,7 @@ AIR302_names.py:282:8: AIR302 `airflow.utils.helpers.cross_downstream` is remove 281 | # airflow.utils.helpers 282 | chain, cross_downstream | ^^^^^^^^^^^^^^^^ AIR302 -283 | +283 | 284 | # airflow.utils.state | = help: Use `airflow.models.baseoperator.cross_downstream` instead @@ -1035,7 +1034,7 @@ AIR302_names.py:285:1: AIR302 `airflow.utils.state.SHUTDOWN` is removed in Airfl 284 | # airflow.utils.state 285 | SHUTDOWN, terminating_states | ^^^^^^^^ AIR302 -286 | +286 | 287 | # airflow.utils.trigger_rule | @@ -1044,7 +1043,7 @@ AIR302_names.py:285:11: AIR302 `airflow.utils.state.terminating_states` is remov 284 | # airflow.utils.state 285 | SHUTDOWN, terminating_states | ^^^^^^^^^^^^^^^^^^ AIR302 -286 | +286 | 287 | # airflow.utils.trigger_rule | @@ -1062,7 +1061,7 @@ AIR302_names.py:289:13: AIR302 `airflow.utils.trigger_rule.TriggerRule.NONE_FAIL 288 | TriggerRule.DUMMY 289 | TriggerRule.NONE_FAILED_OR_SKIPPED | ^^^^^^^^^^^^^^^^^^^^^^ AIR302 -290 | +290 | 291 | # airflow.www.auth | @@ -1081,7 +1080,7 @@ AIR302_names.py:293:1: AIR302 `airflow.www.auth.has_access_dataset` is removed i 292 | has_access 293 | has_access_dataset | ^^^^^^^^^^^^^^^^^^ AIR302 -294 | +294 | 295 | # airflow.www.utils | = help: Use `airflow.www.auth.has_access_dataset.has_access_asset` instead diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR303_AIR303.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR303_AIR303.py.snap index d9833112ad14c..ddfe41a1da6e8 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR303_AIR303.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR303_AIR303.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs -snapshot_kind: text --- AIR303.py:159:1: AIR303 `airflow.hooks.S3_hook.provide_bucket_name` is moved into `amazon` provider in Airflow 3.0; | @@ -116,7 +115,7 @@ AIR303.py:169:1: AIR303 `airflow.operators.s3_to_redshift_operator.S3ToRedshiftT 168 | S3ToRedshiftOperator() 169 | S3ToRedshiftTransfer() | ^^^^^^^^^^^^^^^^^^^^ AIR303 -170 | +170 | 171 | # apache-airflow-providers-celery | = help: Install `apache-airflow-provider-amazon>=1.0.0` and use `airflow.providers.amazon.aws.transfers.s3_to_redshift.S3ToRedshiftOperator` instead. @@ -158,7 +157,7 @@ AIR303.py:175:1: AIR303 `airflow.executors.celery_kubernetes_executor.CeleryKube 174 | CeleryExecutor() 175 | CeleryKubernetesExecutor() | ^^^^^^^^^^^^^^^^^^^^^^^^ AIR303 -176 | +176 | 177 | # apache-airflow-providers-common-sql | = help: Install `apache-airflow-provider-celery>=3.3.0` and use `airflow.providers.celery.executors.celery_kubernetes_executor.CeleryKubernetesExecutor` instead. @@ -453,7 +452,7 @@ AIR303.py:206:1: AIR303 `airflow.operators.check_operator.ValueCheckOperator` is 205 | ThresholdCheckOperator() 206 | ValueCheckOperator() | ^^^^^^^^^^^^^^^^^^ AIR303 -207 | +207 | 208 | # apache-airflow-providers-daskexecutor | = help: Install `apache-airflow-provider-common-sql>=1.1.0` and use `airflow.providers.common.sql.operators.sql.SQLValueCheckOperator` instead. @@ -463,7 +462,7 @@ AIR303.py:209:1: AIR303 `airflow.executors.dask_executor.DaskExecutor` is moved 208 | # apache-airflow-providers-daskexecutor 209 | DaskExecutor() | ^^^^^^^^^^^^ AIR303 -210 | +210 | 211 | # apache-airflow-providers-docker | = help: Install `apache-airflow-provider-daskexecutor>=1.0.0` and use `airflow.providers.daskexecutor.executors.dask_executor.DaskExecutor` instead. @@ -483,7 +482,7 @@ AIR303.py:213:1: AIR303 `airflow.operators.docker_operator.DockerOperator` is mo 212 | DockerHook() 213 | DockerOperator() | ^^^^^^^^^^^^^^ AIR303 -214 | +214 | 215 | # apache-airflow-providers-apache-druid | = help: Install `apache-airflow-provider-docker>=1.0.0` and use `airflow.providers.docker.operators.docker.DockerOperator` instead. @@ -514,7 +513,7 @@ AIR303.py:218:1: AIR303 `airflow.operators.druid_check_operator.DruidCheckOperat 217 | DruidHook() 218 | DruidCheckOperator() | ^^^^^^^^^^^^^^^^^^ AIR303 -219 | +219 | 220 | # apache-airflow-providers-apache-hdfs | = help: Install `apache-airflow-provider-apache-druid>=1.0.0` and use `DruidCheckOperator` instead. @@ -534,7 +533,7 @@ AIR303.py:222:1: AIR303 `airflow.sensors.web_hdfs_sensor.WebHdfsSensor` is moved 221 | WebHDFSHook() 222 | WebHdfsSensor() | ^^^^^^^^^^^^^ AIR303 -223 | +223 | 224 | # apache-airflow-providers-apache-hive | = help: Install `apache-airflow-provider-apache-hdfs>=1.0.0` and use `airflow.providers.apache.hdfs.sensors.web_hdfs.WebHdfsSensor` instead. @@ -708,7 +707,7 @@ AIR303.py:240:1: AIR303 `airflow.sensors.named_hive_partition_sensor.NamedHivePa 239 | MetastorePartitionSensor() 240 | NamedHivePartitionSensor() | ^^^^^^^^^^^^^^^^^^^^^^^^ AIR303 -241 | +241 | 242 | # apache-airflow-providers-http | = help: Install `apache-airflow-provider-apache-hive>=1.0.0` and use `airflow.providers.apache.hive.sensors.named_hive_partition.NamedHivePartitionSensor` instead. @@ -739,7 +738,7 @@ AIR303.py:245:1: AIR303 `airflow.operators.http_operator.SimpleHttpOperator` is 244 | HttpSensor() 245 | SimpleHttpOperator() | ^^^^^^^^^^^^^^^^^^ AIR303 -246 | +246 | 247 | # apache-airflow-providers-jdbc | = help: Install `apache-airflow-provider-http>=1.0.0` and use `airflow.providers.http.operators.http.SimpleHttpOperator` instead. @@ -770,7 +769,7 @@ AIR303.py:250:1: AIR303 `airflow.operators.jdbc_operator.JdbcOperator` is moved 249 | JdbcHook() 250 | JdbcOperator() | ^^^^^^^^^^^^ AIR303 -251 | +251 | 252 | # apache-airflow-providers-fab | = help: Install `apache-airflow-provider-jdbc>=1.0.0` and use `airflow.providers.jdbc.operators.jdbc.JdbcOperator` instead. @@ -844,7 +843,7 @@ AIR303.py:258:1: AIR303 `airflow.www.security.FabAirflowSecurityManagerOverride` 257 | FabAuthManager() 258 | FabAirflowSecurityManagerOverride() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR303 -259 | +259 | 260 | # apache-airflow-providers-cncf-kubernetes | = help: Install `apache-airflow-provider-fab>=1.0.0` and use `airflow.providers.fab.auth_manager.security_manager.override.FabAirflowSecurityManagerOverride` instead. @@ -1062,7 +1061,7 @@ AIR303.py:280:1: AIR303 `airflow.kubernetes.secret.Secret` is moved into `cncf-k 279 | VolumeMount() 280 | Secret() | ^^^^^^ AIR303 -281 | +281 | 282 | add_pod_suffix() | = help: Install `apache-airflow-provider-cncf-kubernetes>=7.4.0` and use `airflow.providers.cncf.kubernetes.secret.Secret` instead. @@ -1070,7 +1069,7 @@ AIR303.py:280:1: AIR303 `airflow.kubernetes.secret.Secret` is moved into `cncf-k AIR303.py:282:1: AIR303 `airflow.kubernetes.kubernetes_helper_functions.add_pod_suffix` is moved into `cncf-kubernetes` provider in Airflow 3.0; | 280 | Secret() -281 | +281 | 282 | add_pod_suffix() | ^^^^^^^^^^^^^^ AIR303 283 | add_pod_suffix2() @@ -1298,7 +1297,7 @@ AIR303.py:307:1: AIR303 `airflow.operators.mssql_to_hive.MsSqlToHiveTransfer` is 306 | MsSqlToHiveOperator() 307 | MsSqlToHiveTransfer() | ^^^^^^^^^^^^^^^^^^^ AIR303 -308 | +308 | 309 | # apache-airflow-providers-mysql | = help: Install `apache-airflow-provider-apache-hive>=1.0.0` and use `airflow.providers.apache.hive.transfers.mssql_to_hive.MsSqlToHiveOperator` instead. @@ -1384,7 +1383,7 @@ AIR303.py:317:1: AIR303 `airflow.operators.presto_to_mysql.PrestoToMySqlTransfer 316 | PrestoToMySqlOperator() 317 | PrestoToMySqlTransfer() | ^^^^^^^^^^^^^^^^^^^^^ AIR303 -318 | +318 | 319 | # apache-airflow-providers-oracle | = help: Install `apache-airflow-provider-mysql>=1.0.0` and use `airflow.providers.mysql.transfers.presto_to_mysql.PrestoToMySqlOperator` instead. @@ -1404,7 +1403,7 @@ AIR303.py:321:1: AIR303 `airflow.operators.oracle_operator.OracleOperator` is mo 320 | OracleHook() 321 | OracleOperator() | ^^^^^^^^^^^^^^ AIR303 -322 | +322 | 323 | # apache-airflow-providers-papermill | = help: Install `apache-airflow-provider-oracle>=1.0.0` and use `airflow.providers.oracle.operators.oracle.OracleOperator` instead. @@ -1414,7 +1413,7 @@ AIR303.py:324:1: AIR303 `airflow.operators.papermill_operator.PapermillOperator` 323 | # apache-airflow-providers-papermill 324 | PapermillOperator() | ^^^^^^^^^^^^^^^^^ AIR303 -325 | +325 | 326 | # apache-airflow-providers-apache-pig | = help: Install `apache-airflow-provider-papermill>=1.0.0` and use `airflow.providers.papermill.operators.papermill.PapermillOperator` instead. @@ -1434,7 +1433,7 @@ AIR303.py:328:1: AIR303 `airflow.operators.pig_operator.PigOperator` is moved in 327 | PigCliHook() 328 | PigOperator() | ^^^^^^^^^^^ AIR303 -329 | +329 | 330 | # apache-airflow-providers-postgres | = help: Install `apache-airflow-provider-apache-pig>=1.0.0` and use `airflow.providers.apache.pig.operators.pig.PigOperator` instead. @@ -1465,7 +1464,7 @@ AIR303.py:333:1: AIR303 `airflow.operators.postgres_operator.PostgresOperator` i 332 | PostgresHook() 333 | PostgresOperator() | ^^^^^^^^^^^^^^^^ AIR303 -334 | +334 | 335 | # apache-airflow-providers-presto | = help: Install `apache-airflow-provider-postgres>=1.0.0` and use `airflow.providers.postgres.operators.postgres.PostgresOperator` instead. @@ -1475,7 +1474,7 @@ AIR303.py:336:1: AIR303 `airflow.hooks.presto_hook.PrestoHook` is moved into `pr 335 | # apache-airflow-providers-presto 336 | PrestoHook() | ^^^^^^^^^^ AIR303 -337 | +337 | 338 | # apache-airflow-providers-samba | = help: Install `apache-airflow-provider-presto>=1.0.0` and use `airflow.providers.presto.hooks.presto.PrestoHook` instead. @@ -1485,7 +1484,7 @@ AIR303.py:339:1: AIR303 `airflow.hooks.samba_hook.SambaHook` is moved into `samb 338 | # apache-airflow-providers-samba 339 | SambaHook() | ^^^^^^^^^ AIR303 -340 | +340 | 341 | # apache-airflow-providers-slack | = help: Install `apache-airflow-provider-samba>=1.0.0` and use `airflow.providers.samba.hooks.samba.SambaHook` instead. @@ -1516,7 +1515,7 @@ AIR303.py:344:1: AIR303 `airflow.operators.slack_operator.SlackAPIPostOperator` 343 | SlackAPIOperator() 344 | SlackAPIPostOperator() | ^^^^^^^^^^^^^^^^^^^^ AIR303 -345 | +345 | 346 | # apache-airflow-providers-sqlite | = help: Install `apache-airflow-provider-slack>=1.0.0` and use `airflow.providers.slack.operators.slack.SlackAPIPostOperator` instead. @@ -1536,7 +1535,7 @@ AIR303.py:348:1: AIR303 `airflow.operators.sqlite_operator.SqliteOperator` is mo 347 | SqliteHook() 348 | SqliteOperator() | ^^^^^^^^^^^^^^ AIR303 -349 | +349 | 350 | # apache-airflow-providers-zendesk | = help: Install `apache-airflow-provider-sqlite>=1.0.0` and use `airflow.providers.sqlite.operators.sqlite.SqliteOperator` instead. diff --git a/crates/ruff_linter/src/rules/eradicate/snapshots/ruff_linter__rules__eradicate__tests__ERA001_ERA001.py.snap b/crates/ruff_linter/src/rules/eradicate/snapshots/ruff_linter__rules__eradicate__tests__ERA001_ERA001.py.snap index 7c1f04b602b98..37331b90077ad 100644 --- a/crates/ruff_linter/src/rules/eradicate/snapshots/ruff_linter__rules__eradicate__tests__ERA001_ERA001.py.snap +++ b/crates/ruff_linter/src/rules/eradicate/snapshots/ruff_linter__rules__eradicate__tests__ERA001_ERA001.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/eradicate/mod.rs -snapshot_kind: text --- ERA001.py:1:1: ERA001 Found commented-out code | @@ -59,7 +58,7 @@ ERA001.py:5:1: ERA001 Found commented-out code 4 | a = 4 5 | #foo(1, 2, 3) | ^^^^^^^^^^^^^ ERA001 -6 | +6 | 7 | def foo(x, y, z): | = help: Remove commented-out code @@ -152,7 +151,7 @@ ERA001.py:27:5: ERA001 Found commented-out code ERA001.py:32:1: ERA001 Found commented-out code | 30 | #import os # noqa -31 | +31 | 32 | # case 1: | ^^^^^^^^^ ERA001 33 | # try: @@ -349,7 +348,7 @@ ERA001.py:78:1: ERA001 Found commented-out code 77 | # "rich", 78 | # ] | ^^^ ERA001 -79 | +79 | 80 | # Script tag block followed by normal block (Ok) | = help: Remove commented-out code diff --git a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT101_YTT101.py.snap b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT101_YTT101.py.snap index e0db955426d80..bd81dd2410289 100644 --- a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT101_YTT101.py.snap +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT101_YTT101.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_2020/mod.rs -snapshot_kind: text --- YTT101.py:6:7: YTT101 `sys.version[:3]` referenced (python3.10), use `sys.version_info` | 4 | print(sys.version) -5 | +5 | 6 | print(sys.version[:3]) | ^^^^^^^^^^^ YTT101 7 | print(version[:3]) @@ -26,6 +25,6 @@ YTT101.py:8:7: YTT101 `sys.version[:3]` referenced (python3.10), use `sys.versio 7 | print(version[:3]) 8 | print(v[:3]) | ^ YTT101 - 9 | + 9 | 10 | # the tool is timid and only flags certain numeric slices | diff --git a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT102_YTT102.py.snap b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT102_YTT102.py.snap index c0eb5ebed5a09..b5b82d89fa9ec 100644 --- a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT102_YTT102.py.snap +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT102_YTT102.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_2020/mod.rs -snapshot_kind: text --- YTT102.py:4:12: YTT102 `sys.version[2]` referenced (python3.10), use `sys.version_info` | 2 | from sys import version -3 | +3 | 4 | py_minor = sys.version[2] | ^^^^^^^^^^^ YTT102 5 | py_minor = version[2] diff --git a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT103_YTT103.py.snap b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT103_YTT103.py.snap index ec2eff1b5a322..fb884488c8308 100644 --- a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT103_YTT103.py.snap +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT103_YTT103.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_2020/mod.rs -snapshot_kind: text --- YTT103.py:4:1: YTT103 `sys.version` compared to string (python3.10), use `sys.version_info` | 2 | from sys import version -3 | +3 | 4 | version < "3.5" | ^^^^^^^ YTT103 5 | sys.version < "3.5" diff --git a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT201_YTT201.py.snap b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT201_YTT201.py.snap index 9278d8196bb23..c2ae9a26987b0 100644 --- a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT201_YTT201.py.snap +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT201_YTT201.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_2020/mod.rs -snapshot_kind: text --- YTT201.py:7:7: YTT201 `sys.version_info[0] == 3` referenced (python4), use `>=` | 5 | PY3 = sys.version_info[0] >= 3 -6 | +6 | 7 | PY3 = sys.version_info[0] == 3 | ^^^^^^^^^^^^^^^^^^^ YTT201 8 | PY3 = version_info[0] == 3 diff --git a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT202_YTT202.py.snap b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT202_YTT202.py.snap index 683a9711e1e10..da923c2649d39 100644 --- a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT202_YTT202.py.snap +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT202_YTT202.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_2020/mod.rs -snapshot_kind: text --- YTT202.py:4:4: YTT202 `six.PY3` referenced (python4), use `not six.PY2` | 2 | from six import PY3 -3 | +3 | 4 | if six.PY3: | ^^^^^^^ YTT202 5 | print("3") diff --git a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT203_YTT203.py.snap b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT203_YTT203.py.snap index fa179afc0d4d6..98340c2c0d41e 100644 --- a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT203_YTT203.py.snap +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT203_YTT203.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_2020/mod.rs -snapshot_kind: text --- YTT203.py:4:1: YTT203 `sys.version_info[1]` compared to integer (python4), compare `sys.version_info` to tuple | 2 | from sys import version_info -3 | +3 | 4 | sys.version_info[1] >= 5 | ^^^^^^^^^^^^^^^^^^^ YTT203 5 | version_info[1] < 6 diff --git a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT204_YTT204.py.snap b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT204_YTT204.py.snap index 61b5b9c5d6b08..0d59be0063afd 100644 --- a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT204_YTT204.py.snap +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT204_YTT204.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_2020/mod.rs -snapshot_kind: text --- YTT204.py:4:1: YTT204 `sys.version_info.minor` compared to integer (python4), compare `sys.version_info` to tuple | 2 | from sys import version_info -3 | +3 | 4 | sys.version_info.minor <= 7 | ^^^^^^^^^^^^^^^^^^^^^^ YTT204 5 | version_info.minor > 8 diff --git a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT301_YTT301.py.snap b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT301_YTT301.py.snap index 45a73e3d8e3f6..df1b27d3302d1 100644 --- a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT301_YTT301.py.snap +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT301_YTT301.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_2020/mod.rs -snapshot_kind: text --- YTT301.py:4:12: YTT301 `sys.version[0]` referenced (python10), use `sys.version_info` | 2 | from sys import version -3 | +3 | 4 | py_major = sys.version[0] | ^^^^^^^^^^^ YTT301 5 | py_major = version[0] diff --git a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT302_YTT302.py.snap b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT302_YTT302.py.snap index 9eb476ff8fd70..27e563290e950 100644 --- a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT302_YTT302.py.snap +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT302_YTT302.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_2020/mod.rs -snapshot_kind: text --- YTT302.py:4:1: YTT302 `sys.version` compared to string (python10), use `sys.version_info` | 2 | from sys import version -3 | +3 | 4 | version < "3" | ^^^^^^^ YTT302 5 | sys.version < "3" diff --git a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT303_YTT303.py.snap b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT303_YTT303.py.snap index bc7af81ce5823..8cda6c210886b 100644 --- a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT303_YTT303.py.snap +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT303_YTT303.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_2020/mod.rs -snapshot_kind: text --- YTT303.py:4:7: YTT303 `sys.version[:1]` referenced (python10), use `sys.version_info` | 2 | from sys import version -3 | +3 | 4 | print(sys.version[:1]) | ^^^^^^^^^^^ YTT303 5 | print(version[:1]) diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__ignore_fully_untyped.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__ignore_fully_untyped.snap index c95591ac2190b..71e528ec5dfb4 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__ignore_fully_untyped.snap +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__ignore_fully_untyped.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs -snapshot_kind: text --- ignore_fully_untyped.py:24:5: ANN201 [*] Missing return type annotation for public function `error_partially_typed_1` | @@ -55,7 +54,7 @@ ignore_fully_untyped.py:32:5: ANN201 [*] Missing return type annotation for publ ignore_fully_untyped.py:43:9: ANN201 [*] Missing return type annotation for public function `error_typed_self` | 41 | pass -42 | +42 | 43 | def error_typed_self(self: X): | ^^^^^^^^^^^^^^^^ ANN201 44 | pass diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__simple_magic_methods.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__simple_magic_methods.snap index 2b0d08f1fd09c..bc8e91807bda8 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__simple_magic_methods.snap +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__simple_magic_methods.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs -snapshot_kind: text --- simple_magic_methods.py:2:9: ANN204 [*] Missing return type annotation for special method `__str__` | @@ -22,7 +21,7 @@ simple_magic_methods.py:2:9: ANN204 [*] Missing return type annotation for speci simple_magic_methods.py:5:9: ANN204 [*] Missing return type annotation for special method `__repr__` | 3 | ... -4 | +4 | 5 | def __repr__(self): | ^^^^^^^^ ANN204 6 | ... @@ -42,7 +41,7 @@ simple_magic_methods.py:5:9: ANN204 [*] Missing return type annotation for speci simple_magic_methods.py:8:9: ANN204 [*] Missing return type annotation for special method `__len__` | 6 | ... -7 | +7 | 8 | def __len__(self): | ^^^^^^^ ANN204 9 | ... @@ -62,7 +61,7 @@ simple_magic_methods.py:8:9: ANN204 [*] Missing return type annotation for speci simple_magic_methods.py:11:9: ANN204 [*] Missing return type annotation for special method `__length_hint__` | 9 | ... -10 | +10 | 11 | def __length_hint__(self): | ^^^^^^^^^^^^^^^ ANN204 12 | ... @@ -82,7 +81,7 @@ simple_magic_methods.py:11:9: ANN204 [*] Missing return type annotation for spec simple_magic_methods.py:14:9: ANN204 [*] Missing return type annotation for special method `__init__` | 12 | ... -13 | +13 | 14 | def __init__(self): | ^^^^^^^^ ANN204 15 | ... @@ -102,7 +101,7 @@ simple_magic_methods.py:14:9: ANN204 [*] Missing return type annotation for spec simple_magic_methods.py:17:9: ANN204 [*] Missing return type annotation for special method `__del__` | 15 | ... -16 | +16 | 17 | def __del__(self): | ^^^^^^^ ANN204 18 | ... @@ -122,7 +121,7 @@ simple_magic_methods.py:17:9: ANN204 [*] Missing return type annotation for spec simple_magic_methods.py:20:9: ANN204 [*] Missing return type annotation for special method `__bool__` | 18 | ... -19 | +19 | 20 | def __bool__(self): | ^^^^^^^^ ANN204 21 | ... @@ -142,7 +141,7 @@ simple_magic_methods.py:20:9: ANN204 [*] Missing return type annotation for spec simple_magic_methods.py:23:9: ANN204 [*] Missing return type annotation for special method `__bytes__` | 21 | ... -22 | +22 | 23 | def __bytes__(self): | ^^^^^^^^^ ANN204 24 | ... @@ -162,7 +161,7 @@ simple_magic_methods.py:23:9: ANN204 [*] Missing return type annotation for spec simple_magic_methods.py:26:9: ANN204 [*] Missing return type annotation for special method `__format__` | 24 | ... -25 | +25 | 26 | def __format__(self, format_spec): | ^^^^^^^^^^ ANN204 27 | ... @@ -182,7 +181,7 @@ simple_magic_methods.py:26:9: ANN204 [*] Missing return type annotation for spec simple_magic_methods.py:29:9: ANN204 [*] Missing return type annotation for special method `__contains__` | 27 | ... -28 | +28 | 29 | def __contains__(self, item): | ^^^^^^^^^^^^ ANN204 30 | ... @@ -202,7 +201,7 @@ simple_magic_methods.py:29:9: ANN204 [*] Missing return type annotation for spec simple_magic_methods.py:32:9: ANN204 [*] Missing return type annotation for special method `__complex__` | 30 | ... -31 | +31 | 32 | def __complex__(self): | ^^^^^^^^^^^ ANN204 33 | ... @@ -222,7 +221,7 @@ simple_magic_methods.py:32:9: ANN204 [*] Missing return type annotation for spec simple_magic_methods.py:35:9: ANN204 [*] Missing return type annotation for special method `__int__` | 33 | ... -34 | +34 | 35 | def __int__(self): | ^^^^^^^ ANN204 36 | ... @@ -242,7 +241,7 @@ simple_magic_methods.py:35:9: ANN204 [*] Missing return type annotation for spec simple_magic_methods.py:38:9: ANN204 [*] Missing return type annotation for special method `__float__` | 36 | ... -37 | +37 | 38 | def __float__(self): | ^^^^^^^^^ ANN204 39 | ... @@ -262,7 +261,7 @@ simple_magic_methods.py:38:9: ANN204 [*] Missing return type annotation for spec simple_magic_methods.py:41:9: ANN204 [*] Missing return type annotation for special method `__index__` | 39 | ... -40 | +40 | 41 | def __index__(self): | ^^^^^^^^^ ANN204 42 | ... diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC105_ASYNC105.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC105_ASYNC105.py.snap index aa8fbdfacfa8e..13b59fdeccabd 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC105_ASYNC105.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC105_ASYNC105.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs -snapshot_kind: text --- ASYNC105.py:30:5: ASYNC105 [*] Call to `trio.aclose_forcefully` is not immediately awaited | @@ -468,7 +467,7 @@ ASYNC105.py:53:5: ASYNC105 [*] Call to `trio.lowlevel.wait_writable` is not imme 52 | trio.lowlevel.wait_task_rescheduled(foo) 53 | trio.lowlevel.wait_writable(foo) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC105 -54 | +54 | 55 | async with await trio.open_file(foo): # Ok | = help: Add `await` @@ -486,7 +485,7 @@ ASYNC105.py:53:5: ASYNC105 [*] Call to `trio.lowlevel.wait_writable` is not imme ASYNC105.py:58:16: ASYNC105 [*] Call to `trio.open_file` is not immediately awaited | 56 | pass -57 | +57 | 58 | async with trio.open_file(foo): # ASYNC105 | ^^^^^^^^^^^^^^^^^^^ ASYNC105 59 | pass diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC115_ASYNC115.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC115_ASYNC115.py.snap index c74f845ec576f..ab2185ba56c52 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC115_ASYNC115.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC115_ASYNC115.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs -snapshot_kind: text --- ASYNC115.py:5:11: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)` | 3 | from trio import sleep -4 | +4 | 5 | await trio.sleep(0) # ASYNC115 | ^^^^^^^^^^^^^ ASYNC115 6 | await trio.sleep(1) # OK @@ -26,7 +25,7 @@ ASYNC115.py:5:11: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio ASYNC115.py:11:5: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)` | 9 | await trio.sleep() # OK -10 | +10 | 11 | trio.sleep(0) # ASYNC115 | ^^^^^^^^^^^^^ ASYNC115 12 | foo = 0 @@ -47,10 +46,10 @@ ASYNC115.py:11:5: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio ASYNC115.py:17:5: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)` | 15 | time.sleep(0) # OK -16 | +16 | 17 | sleep(0) # ASYNC115 | ^^^^^^^^ ASYNC115 -18 | +18 | 19 | bar = "bar" | = help: Replace with `trio.lowlevel.checkpoint()` @@ -68,7 +67,7 @@ ASYNC115.py:17:5: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio ASYNC115.py:48:14: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)` | 46 | import trio -47 | +47 | 48 | trio.run(trio.sleep(0)) # ASYNC115 | ^^^^^^^^^^^^^ ASYNC115 | @@ -137,7 +136,7 @@ ASYNC115.py:59:11: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `tri ASYNC115.py:85:11: ASYNC115 [*] Use `asyncio.lowlevel.checkpoint()` instead of `asyncio.sleep(0)` | 83 | from anyio import sleep -84 | +84 | 85 | await anyio.sleep(0) # ASYNC115 | ^^^^^^^^^^^^^^ ASYNC115 86 | await anyio.sleep(1) # OK @@ -166,7 +165,7 @@ ASYNC115.py:85:11: ASYNC115 [*] Use `asyncio.lowlevel.checkpoint()` instead of ` ASYNC115.py:91:5: ASYNC115 [*] Use `asyncio.lowlevel.checkpoint()` instead of `asyncio.sleep(0)` | 89 | await anyio.sleep() # OK -90 | +90 | 91 | anyio.sleep(0) # ASYNC115 | ^^^^^^^^^^^^^^ ASYNC115 92 | foo = 0 @@ -195,10 +194,10 @@ ASYNC115.py:91:5: ASYNC115 [*] Use `asyncio.lowlevel.checkpoint()` instead of `a ASYNC115.py:97:5: ASYNC115 [*] Use `asyncio.lowlevel.checkpoint()` instead of `asyncio.sleep(0)` | 95 | time.sleep(0) # OK -96 | +96 | 97 | sleep(0) # ASYNC115 | ^^^^^^^^ ASYNC115 -98 | +98 | 99 | bar = "bar" | = help: Replace with `asyncio.lowlevel.checkpoint()` @@ -224,7 +223,7 @@ ASYNC115.py:97:5: ASYNC115 [*] Use `asyncio.lowlevel.checkpoint()` instead of `a ASYNC115.py:128:15: ASYNC115 [*] Use `asyncio.lowlevel.checkpoint()` instead of `asyncio.sleep(0)` | 126 | import anyio -127 | +127 | 128 | anyio.run(anyio.sleep(0)) # ASYNC115 | ^^^^^^^^^^^^^^ ASYNC115 | diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC116_ASYNC116.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC116_ASYNC116.py.snap index 1de308a83ef84..c06800468520e 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC116_ASYNC116.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC116_ASYNC116.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs -snapshot_kind: text --- ASYNC116.py:11:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` | 10 | # These examples are probably not meant to ever wake up: 11 | await trio.sleep(100000) # error: 116, "async" | ^^^^^^^^^^^^^^^^^^ ASYNC116 -12 | +12 | 13 | # 'inf literal' overflow trick | = help: Replace with `trio.sleep_forever()` @@ -27,7 +26,7 @@ ASYNC116.py:14:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usu 13 | # 'inf literal' overflow trick 14 | await trio.sleep(1e999) # error: 116, "async" | ^^^^^^^^^^^^^^^^^ ASYNC116 -15 | +15 | 16 | await trio.sleep(86399) | = help: Replace with `trio.sleep_forever()` @@ -68,7 +67,7 @@ ASYNC116.py:19:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usu 18 | await trio.sleep(86400.01) # error: 116, "async" 19 | await trio.sleep(86401) # error: 116, "async" | ^^^^^^^^^^^^^^^^^ ASYNC116 -20 | +20 | 21 | await trio.sleep(-1) # will raise a runtime error | = help: Replace with `trio.sleep_forever()` @@ -153,7 +152,7 @@ ASYNC116.py:64:11: ASYNC116 [*] `asyncio.sleep()` with >24 hour interval should 63 | # These examples are probably not meant to ever wake up: 64 | await anyio.sleep(100000) # error: 116, "async" | ^^^^^^^^^^^^^^^^^^^ ASYNC116 -65 | +65 | 66 | # 'inf literal' overflow trick | = help: Replace with `asyncio.sleep_forever()` @@ -181,7 +180,7 @@ ASYNC116.py:67:11: ASYNC116 [*] `asyncio.sleep()` with >24 hour interval should 66 | # 'inf literal' overflow trick 67 | await anyio.sleep(1e999) # error: 116, "async" | ^^^^^^^^^^^^^^^^^^ ASYNC116 -68 | +68 | 69 | await anyio.sleep(86399) | = help: Replace with `asyncio.sleep_forever()` @@ -238,7 +237,7 @@ ASYNC116.py:72:11: ASYNC116 [*] `asyncio.sleep()` with >24 hour interval should 71 | await anyio.sleep(86400.01) # error: 116, "async" 72 | await anyio.sleep(86401) # error: 116, "async" | ^^^^^^^^^^^^^^^^^^ ASYNC116 -73 | +73 | 74 | await anyio.sleep(-1) # will raise a runtime error | = help: Replace with `asyncio.sleep_forever()` diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC210_ASYNC210.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC210_ASYNC210.py.snap index 965aedd915493..3b05d9961dc7d 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC210_ASYNC210.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC210_ASYNC210.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs -snapshot_kind: text --- ASYNC210.py:8:5: ASYNC210 Async functions should not call blocking HTTP methods | @@ -71,7 +70,7 @@ ASYNC210.py:32:11: ASYNC210 Async functions should not call blocking HTTP method 31 | print(requests.get()) # ASYNC210 32 | print(requests.get(requests.get())) # ASYNC210 | ^^^^^^^^^^^^ ASYNC210 -33 | +33 | 34 | requests.options() # ASYNC210 | @@ -81,14 +80,14 @@ ASYNC210.py:32:24: ASYNC210 Async functions should not call blocking HTTP method 31 | print(requests.get()) # ASYNC210 32 | print(requests.get(requests.get())) # ASYNC210 | ^^^^^^^^^^^^ ASYNC210 -33 | +33 | 34 | requests.options() # ASYNC210 | ASYNC210.py:34:5: ASYNC210 Async functions should not call blocking HTTP methods | 32 | print(requests.get(requests.get())) # ASYNC210 -33 | +33 | 34 | requests.options() # ASYNC210 | ^^^^^^^^^^^^^^^^ ASYNC210 35 | requests.head() # ASYNC210 @@ -146,7 +145,7 @@ ASYNC210.py:39:5: ASYNC210 Async functions should not call blocking HTTP methods ASYNC210.py:42:5: ASYNC210 Async functions should not call blocking HTTP methods | 40 | requests.foo() -41 | +41 | 42 | httpx.options("") # ASYNC210 | ^^^^^^^^^^^^^ ASYNC210 43 | httpx.head("") # ASYNC210 @@ -204,7 +203,7 @@ ASYNC210.py:47:5: ASYNC210 Async functions should not call blocking HTTP methods ASYNC210.py:50:5: ASYNC210 Async functions should not call blocking HTTP methods | 48 | httpx.foo() # Ok -49 | +49 | 50 | urllib3.request() # ASYNC210 | ^^^^^^^^^^^^^^^ ASYNC210 51 | urllib3.request(...) # ASYNC210 @@ -215,16 +214,16 @@ ASYNC210.py:51:5: ASYNC210 Async functions should not call blocking HTTP methods 50 | urllib3.request() # ASYNC210 51 | urllib3.request(...) # ASYNC210 | ^^^^^^^^^^^^^^^ ASYNC210 -52 | +52 | 53 | urllib.request.urlopen("") # ASYNC210 | ASYNC210.py:53:5: ASYNC210 Async functions should not call blocking HTTP methods | 51 | urllib3.request(...) # ASYNC210 -52 | +52 | 53 | urllib.request.urlopen("") # ASYNC210 | ^^^^^^^^^^^^^^^^^^^^^^ ASYNC210 -54 | +54 | 55 | r = {} | diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC220_ASYNC22x.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC220_ASYNC22x.py.snap index 89188ba17991a..6be0e845eac40 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC220_ASYNC22x.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC220_ASYNC22x.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs -snapshot_kind: text --- ASYNC22x.py:31:5: ASYNC220 Async functions should not create subprocesses with blocking methods | @@ -45,7 +44,7 @@ ASYNC22x.py:76:5: ASYNC220 Async functions should not create subprocesses with b 75 | os.spawnl(mode=os.P_NOWAIT) # ASYNC220 76 | os.spawnl(mode=P_NOWAIT) # ASYNC220 | ^^^^^^^^^ ASYNC220 -77 | +77 | 78 | P_WAIT = os.P_WAIT | @@ -73,6 +72,6 @@ ASYNC22x.py:88:5: ASYNC220 Async functions should not create subprocesses with b 87 | os.spawnl(1) # ASYNC220 88 | os.spawnl(foo()) # ASYNC220 | ^^^^^^^^^ ASYNC220 -89 | +89 | 90 | # ASYNC222 | diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC221_ASYNC22x.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC221_ASYNC22x.py.snap index 889ed049ad9cc..b838d960264df 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC221_ASYNC22x.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC221_ASYNC22x.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs -snapshot_kind: text --- ASYNC22x.py:8:5: ASYNC221 Async functions should not run processes with blocking methods | @@ -32,14 +31,14 @@ ASYNC22x.py:32:5: ASYNC221 Async functions should not run processes with blockin 31 | subprocess.Popen() # ASYNC220 32 | os.system() # ASYNC221 | ^^^^^^^^^ ASYNC221 -33 | +33 | 34 | system() | ASYNC22x.py:38:5: ASYNC221 Async functions should not run processes with blocking methods | 36 | os.anything() -37 | +37 | 38 | subprocess.run() # ASYNC221 | ^^^^^^^^^^^^^^ ASYNC221 39 | subprocess.call() # ASYNC221 @@ -90,7 +89,7 @@ ASYNC22x.py:43:5: ASYNC221 Async functions should not run processes with blockin 42 | subprocess.getoutput() # ASYNC221 43 | subprocess.getstatusoutput() # ASYNC221 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC221 -44 | +44 | 45 | await async_fun( | @@ -105,7 +104,7 @@ ASYNC22x.py:46:9: ASYNC221 Async functions should not run processes with blockin ASYNC22x.py:54:5: ASYNC221 Async functions should not run processes with blocking methods | 52 | subprocess() -53 | +53 | 54 | os.posix_spawn() # ASYNC221 | ^^^^^^^^^^^^^^ ASYNC221 55 | os.posix_spawnp() # ASYNC221 @@ -116,14 +115,14 @@ ASYNC22x.py:55:5: ASYNC221 Async functions should not run processes with blockin 54 | os.posix_spawn() # ASYNC221 55 | os.posix_spawnp() # ASYNC221 | ^^^^^^^^^^^^^^^ ASYNC221 -56 | +56 | 57 | os.spawn() | ASYNC22x.py:61:5: ASYNC221 Async functions should not run processes with blocking methods | 59 | os.spawnllll() -60 | +60 | 61 | os.spawnl() # ASYNC221 | ^^^^^^^^^ ASYNC221 62 | os.spawnle() # ASYNC221 @@ -194,7 +193,7 @@ ASYNC22x.py:68:5: ASYNC221 Async functions should not run processes with blockin 67 | os.spawnvp() # ASYNC221 68 | os.spawnvpe() # ASYNC221 | ^^^^^^^^^^^ ASYNC221 -69 | +69 | 70 | P_NOWAIT = os.P_NOWAIT | @@ -222,6 +221,6 @@ ASYNC22x.py:83:5: ASYNC221 Async functions should not run processes with blockin 82 | os.spawnl(mode=os.P_WAIT) # ASYNC221 83 | os.spawnl(mode=P_WAIT) # ASYNC221 | ^^^^^^^^^ ASYNC221 -84 | +84 | 85 | # other weird cases: ASYNC220 | diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC222_ASYNC22x.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC222_ASYNC22x.py.snap index 2e89bc3008108..66ca87ebfec16 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC222_ASYNC22x.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC222_ASYNC22x.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs -snapshot_kind: text --- ASYNC22x.py:20:5: ASYNC222 Async functions should not wait on processes with blocking methods | @@ -60,6 +59,6 @@ ASYNC22x.py:95:5: ASYNC222 Async functions should not wait on processes with blo 94 | os.waitid() # ASYNC222 95 | os.waitpid() # ASYNC222 | ^^^^^^^^^^ ASYNC222 -96 | +96 | 97 | os.waitpi() | diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC230_ASYNC230.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC230_ASYNC230.py.snap index f488a34af79b3..b84217540675f 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC230_ASYNC230.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC230_ASYNC230.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs -snapshot_kind: text --- ASYNC230.py:6:5: ASYNC230 Async functions should not open files with blocking methods like `open` | @@ -16,14 +15,14 @@ ASYNC230.py:7:5: ASYNC230 Async functions should not open files with blocking me 6 | open("") # ASYNC230 7 | io.open_code("") # ASYNC230 | ^^^^^^^^^^^^ ASYNC230 -8 | +8 | 9 | with open(""): # ASYNC230 | ASYNC230.py:9:10: ASYNC230 Async functions should not open files with blocking methods like `open` | 7 | io.open_code("") # ASYNC230 - 8 | + 8 | 9 | with open(""): # ASYNC230 | ^^^^ ASYNC230 10 | ... @@ -32,7 +31,7 @@ ASYNC230.py:9:10: ASYNC230 Async functions should not open files with blocking m ASYNC230.py:12:10: ASYNC230 Async functions should not open files with blocking methods like `open` | 10 | ... -11 | +11 | 12 | with open("") as f: # ASYNC230 | ^^^^ ASYNC230 13 | ... @@ -41,7 +40,7 @@ ASYNC230.py:12:10: ASYNC230 Async functions should not open files with blocking ASYNC230.py:15:17: ASYNC230 Async functions should not open files with blocking methods like `open` | 13 | ... -14 | +14 | 15 | with foo(), open(""): # ASYNC230 | ^^^^ ASYNC230 16 | ... @@ -50,7 +49,7 @@ ASYNC230.py:15:17: ASYNC230 Async functions should not open files with blocking ASYNC230.py:18:16: ASYNC230 Async functions should not open files with blocking methods like `open` | 16 | ... -17 | +17 | 18 | async with open(""): # ASYNC230 | ^^^^ ASYNC230 19 | ... @@ -96,7 +95,7 @@ ASYNC230.py:53:9: ASYNC230 Async functions should not open files with blocking m ASYNC230.py:59:5: ASYNC230 Async functions should not open files with blocking methods like `open` | 57 | (p1, p2) = (Path("foo"), Path("bar")) -58 | +58 | 59 | p1.open() # ASYNC230 | ^^^^^^^ ASYNC230 | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S102_S102.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S102_S102.py.snap index 155b1a7cdd25c..28abd3967f1de 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S102_S102.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S102_S102.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S102.py:3:5: S102 Use of `exec` detected | @@ -8,14 +7,14 @@ S102.py:3:5: S102 Use of `exec` detected 2 | # Error 3 | exec('x = 2') | ^^^^ S102 -4 | +4 | 5 | exec('y = 3') | S102.py:5:1: S102 Use of `exec` detected | 3 | exec('x = 2') -4 | +4 | 5 | exec('y = 3') | ^^^^ S102 | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S103_S103.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S103_S103.py.snap index 96bebf6074669..f400e65f28dea 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S103_S103.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S103_S103.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S103.py:6:25: S103 `os.chmod` setting a permissive mask `0o227` on file or directory | 4 | keyfile = "foo" -5 | +5 | 6 | os.chmod("/etc/passwd", 0o227) # Error | ^^^^^ S103 7 | os.chmod("/etc/passwd", 0o7) # Error diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S105_S105.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S105_S105.py.snap index 34ba1ff63c06b..851cb57409bc7 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S105_S105.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S105_S105.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S105.py:13:12: S105 Possible hardcoded password assigned to: "password" | @@ -126,14 +125,14 @@ S105.py:25:19: S105 Possible hardcoded password assigned to: "password" 24 | password: str = "s3cr3t" 25 | password: Final = "s3cr3t" | ^^^^^^^^ S105 -26 | +26 | 27 | d["password"] = "s3cr3t" | S105.py:27:17: S105 Possible hardcoded password assigned to: "password" | 25 | password: Final = "s3cr3t" -26 | +26 | 27 | d["password"] = "s3cr3t" | ^^^^^^^^ S105 28 | d["pass"] = "s3cr3t" @@ -286,14 +285,14 @@ S105.py:49:19: S105 Possible hardcoded password assigned to: "secrete" 48 | MyClass.token = "s3cr3t" 49 | MyClass.secrete = "s3cr3t" | ^^^^^^^^ S105 -50 | +50 | 51 | password == "s3cr3t" | S105.py:51:13: S105 Possible hardcoded password assigned to: "password" | 49 | MyClass.secrete = "s3cr3t" -50 | +50 | 51 | password == "s3cr3t" | ^^^^^^^^ S105 52 | _pass == "s3cr3t" @@ -364,14 +363,14 @@ S105.py:58:21: S105 Possible hardcoded password assigned to: "password" 57 | secrete == "s3cr3t" 58 | password == safe == "s3cr3t" | ^^^^^^^^ S105 -59 | +59 | 60 | if token == "1\n2": | S105.py:60:13: S105 Possible hardcoded password assigned to: "token" | 58 | password == safe == "s3cr3t" -59 | +59 | 60 | if token == "1\n2": | ^^^^^^ S105 61 | pass @@ -380,7 +379,7 @@ S105.py:60:13: S105 Possible hardcoded password assigned to: "token" S105.py:63:13: S105 Possible hardcoded password assigned to: "token" | 61 | pass -62 | +62 | 63 | if token == "3\t4": | ^^^^^^ S105 64 | pass @@ -389,7 +388,7 @@ S105.py:63:13: S105 Possible hardcoded password assigned to: "token" S105.py:66:13: S105 Possible hardcoded password assigned to: "token" | 64 | pass -65 | +65 | 66 | if token == "5\r6": | ^^^^^^ S105 67 | pass diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S108_S108.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S108_S108.py.snap index 93500e05cefe3..2b601edf61da6 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S108_S108.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S108_S108.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S108.py:5:11: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" | 3 | f.write("def") -4 | +4 | 5 | with open("/tmp/abc", "w") as f: | ^^^^^^^^^^ S108 6 | f.write("def") @@ -14,7 +13,7 @@ S108.py:5:11: S108 Probable insecure usage of temporary file or directory: "/tmp S108.py:8:13: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" | 6 | f.write("def") -7 | +7 | 8 | with open(f"/tmp/abc", "w") as f: | ^^^^^^^^ S108 9 | f.write("def") @@ -23,7 +22,7 @@ S108.py:8:13: S108 Probable insecure usage of temporary file or directory: "/tmp S108.py:11:11: S108 Probable insecure usage of temporary file or directory: "/var/tmp/123" | 9 | f.write("def") -10 | +10 | 11 | with open("/var/tmp/123", "w") as f: | ^^^^^^^^^^^^^^ S108 12 | f.write("def") @@ -32,7 +31,7 @@ S108.py:11:11: S108 Probable insecure usage of temporary file or directory: "/va S108.py:14:11: S108 Probable insecure usage of temporary file or directory: "/dev/shm/unit/test" | 12 | f.write("def") -13 | +13 | 14 | with open("/dev/shm/unit/test", "w") as f: | ^^^^^^^^^^^^^^^^^^^^ S108 15 | f.write("def") @@ -49,7 +48,7 @@ S108.py:22:11: S108 Probable insecure usage of temporary file or directory: "/tm S108.py:25:11: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" | 23 | f.write("def") -24 | +24 | 25 | with open("/tmp/abc" f"/tmp/abc", "w") as f: | ^^^^^^^^^^ S108 26 | f.write("def") @@ -58,7 +57,7 @@ S108.py:25:11: S108 Probable insecure usage of temporary file or directory: "/tm S108.py:25:24: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" | 23 | f.write("def") -24 | +24 | 25 | with open("/tmp/abc" f"/tmp/abc", "w") as f: | ^^^^^^^^ S108 26 | f.write("def") diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S108_extend.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S108_extend.snap index 90caacf9dd6c9..bcaf957a3dc11 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S108_extend.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S108_extend.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S108.py:5:11: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" | 3 | f.write("def") -4 | +4 | 5 | with open("/tmp/abc", "w") as f: | ^^^^^^^^^^ S108 6 | f.write("def") @@ -14,7 +13,7 @@ S108.py:5:11: S108 Probable insecure usage of temporary file or directory: "/tmp S108.py:8:13: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" | 6 | f.write("def") -7 | +7 | 8 | with open(f"/tmp/abc", "w") as f: | ^^^^^^^^ S108 9 | f.write("def") @@ -23,7 +22,7 @@ S108.py:8:13: S108 Probable insecure usage of temporary file or directory: "/tmp S108.py:11:11: S108 Probable insecure usage of temporary file or directory: "/var/tmp/123" | 9 | f.write("def") -10 | +10 | 11 | with open("/var/tmp/123", "w") as f: | ^^^^^^^^^^^^^^ S108 12 | f.write("def") @@ -32,7 +31,7 @@ S108.py:11:11: S108 Probable insecure usage of temporary file or directory: "/va S108.py:14:11: S108 Probable insecure usage of temporary file or directory: "/dev/shm/unit/test" | 12 | f.write("def") -13 | +13 | 14 | with open("/dev/shm/unit/test", "w") as f: | ^^^^^^^^^^^^^^^^^^^^ S108 15 | f.write("def") @@ -57,7 +56,7 @@ S108.py:22:11: S108 Probable insecure usage of temporary file or directory: "/tm S108.py:25:11: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" | 23 | f.write("def") -24 | +24 | 25 | with open("/tmp/abc" f"/tmp/abc", "w") as f: | ^^^^^^^^^^ S108 26 | f.write("def") @@ -66,7 +65,7 @@ S108.py:25:11: S108 Probable insecure usage of temporary file or directory: "/tm S108.py:25:24: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" | 23 | f.write("def") -24 | +24 | 25 | with open("/tmp/abc" f"/tmp/abc", "w") as f: | ^^^^^^^^ S108 26 | f.write("def") diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S110_S110.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S110_S110.py.snap index f8482165d581f..ecf235771ff0d 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S110_S110.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S110_S110.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S110.py:3:1: S110 `try`-`except`-`pass` detected, consider logging the exception | @@ -9,7 +8,7 @@ S110.py:3:1: S110 `try`-`except`-`pass` detected, consider logging the exception 3 | / except Exception: 4 | | pass | |________^ S110 -5 | +5 | 6 | try: | @@ -20,6 +19,6 @@ S110.py:8:1: S110 `try`-`except`-`pass` detected, consider logging the exception 8 | / except: 9 | | pass | |________^ S110 -10 | +10 | 11 | try: | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S110_typed.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S110_typed.snap index ed8c875ee47ff..a0971f71ad02e 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S110_typed.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S110_typed.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S110.py:3:1: S110 `try`-`except`-`pass` detected, consider logging the exception | @@ -9,7 +8,7 @@ S110.py:3:1: S110 `try`-`except`-`pass` detected, consider logging the exception 3 | / except Exception: 4 | | pass | |________^ S110 -5 | +5 | 6 | try: | @@ -20,7 +19,7 @@ S110.py:8:1: S110 `try`-`except`-`pass` detected, consider logging the exception 8 | / except: 9 | | pass | |________^ S110 -10 | +10 | 11 | try: | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S112_S112.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S112_S112.py.snap index e7e2cfd249b9b..2df863f5fdcfb 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S112_S112.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S112_S112.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S112.py:3:1: S112 `try`-`except`-`continue` detected, consider logging the exception | @@ -9,7 +8,7 @@ S112.py:3:1: S112 `try`-`except`-`continue` detected, consider logging the excep 3 | / except Exception: 4 | | continue | |____________^ S112 -5 | +5 | 6 | try: | @@ -20,7 +19,7 @@ S112.py:8:1: S112 `try`-`except`-`continue` detected, consider logging the excep 8 | / except: 9 | | continue | |____________^ S112 -10 | +10 | 11 | try: | @@ -31,7 +30,7 @@ S112.py:13:1: S112 `try`-`except`-`continue` detected, consider logging the exce 13 | / except (Exception,): 14 | | continue | |____________^ S112 -15 | +15 | 16 | try: | @@ -42,6 +41,6 @@ S112.py:18:1: S112 `try`-`except`-`continue` detected, consider logging the exce 18 | / except (Exception, ValueError): 19 | | continue | |____________^ S112 -20 | +20 | 21 | try: | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S113_S113.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S113_S113.py.snap index 9d306eb589d79..9ae00a6a68896 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S113_S113.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S113_S113.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S113.py:46:1: S113 Probable use of `requests` call without timeout | @@ -136,14 +135,14 @@ S113.py:59:36: S113 Probable use of `requests` call with timeout set to `None` 58 | requests.head('https://gmail.com') 59 | requests.head('https://gmail.com', timeout=None) | ^^^^^^^^^^^^ S113 -60 | +60 | 61 | httpx.get('https://gmail.com', timeout=None) | S113.py:61:32: S113 Probable use of `httpx` call with timeout set to `None` | 59 | requests.head('https://gmail.com', timeout=None) -60 | +60 | 61 | httpx.get('https://gmail.com', timeout=None) | ^^^^^^^^^^^^ S113 62 | httpx.post('https://gmail.com', timeout=None) @@ -224,14 +223,14 @@ S113.py:69:19: S113 Probable use of `httpx` call with timeout set to `None` 68 | httpx.Client(timeout=None) 69 | httpx.AsyncClient(timeout=None) | ^^^^^^^^^^^^ S113 -70 | +70 | 71 | with httpx.Client(timeout=None) as client: | S113.py:71:19: S113 Probable use of `httpx` call with timeout set to `None` | 69 | httpx.AsyncClient(timeout=None) -70 | +70 | 71 | with httpx.Client(timeout=None) as client: | ^^^^^^^^^^^^ S113 72 | client.get('https://gmail.com') diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S201_S201.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S201_S201.py.snap index 3482b52cc4e7a..11115cc0bae11 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S201_S201.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S201_S201.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S201.py:10:9: S201 Use of `debug=True` in Flask app detected | 9 | # OK 10 | app.run(debug=True) | ^^^^^^^^^^ S201 -11 | +11 | 12 | # Errors | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S301_S301.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S301_S301.py.snap index a383b444660a7..4e27b0d75b536 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S301_S301.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S301_S301.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S301.py:3:1: S301 `pickle` and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue | 1 | import pickle -2 | +2 | 3 | pickle.loads() | ^^^^^^^^^^^^^^ S301 | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S307_S307.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S307_S307.py.snap index eabf6067a29da..7d474f3d31fb4 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S307_S307.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S307_S307.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S307.py:3:7: S307 Use of possibly insecure function; consider using `ast.literal_eval` | 1 | import os -2 | +2 | 3 | print(eval("1+1")) # S307 | ^^^^^^^^^^^ S307 4 | print(eval("os.getcwd()")) # S307 diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S310_S310.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S310_S310.py.snap index 53f29273799e8..1a90de58fad2f 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S310_S310.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S310_S310.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S310.py:6:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. | @@ -37,7 +36,7 @@ S310.py:11:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` 10 | urllib.request.urlopen('file:///foo/bar/baz') 11 | urllib.request.urlopen(url) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 -12 | +12 | 13 | urllib.request.Request(url='http://www.google.com') | @@ -76,14 +75,14 @@ S310.py:21:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` 20 | urllib.request.Request('file:///foo/bar/baz') 21 | urllib.request.Request(url) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 -22 | +22 | 23 | urllib.request.URLopener().open(fullurl='http://www.google.com') | S310.py:23:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. | 21 | urllib.request.Request(url) -22 | +22 | 23 | urllib.request.URLopener().open(fullurl='http://www.google.com') | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 24 | urllib.request.URLopener().open(fullurl=f'http://www.google.com') @@ -174,7 +173,7 @@ S310.py:32:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` 31 | urllib.request.URLopener().open('file:///foo/bar/baz') 32 | urllib.request.URLopener().open(url) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 -33 | +33 | 34 | urllib.request.urlopen(url=urllib.request.Request('http://www.google.com')) | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S311_S311.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S311_S311.py.snap index ac73f2f77e231..858f04e4a3b93 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S311_S311.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S311_S311.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S311.py:10:1: S311 Standard pseudo-random generators are not suitable for cryptographic purposes | @@ -86,6 +85,6 @@ S311.py:18:1: S311 Standard pseudo-random generators are not suitable for crypto 17 | random.triangular() 18 | random.randbytes() | ^^^^^^^^^^^^^^^^^^ S311 -19 | +19 | 20 | # Unrelated | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S312_S312.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S312_S312.py.snap index 4c507202c6cfb..1a4e25fbc6a4f 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S312_S312.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S312_S312.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S312.py:3:1: S312 Telnet-related functions are being called. Telnet is considered insecure. Use SSH or some other encrypted protocol. | 1 | from telnetlib import Telnet -2 | +2 | 3 | Telnet("localhost", 23) | ^^^^^^^^^^^^^^^^^^^^^^^ S312 | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S324_S324.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S324_S324.py.snap index 10318779d9354..c1961029c77d8 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S324_S324.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S324_S324.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S324.py:7:13: S324 Probable use of insecure hash functions in `hashlib`: `md5` | @@ -127,14 +126,14 @@ S324.py:20:13: S324 Probable use of insecure hash functions in `hashlib`: `sha1` 19 | # usedforsecurity arg only available in Python 3.9+ 20 | hashlib.new('sha1', usedforsecurity=True) | ^^^^^^ S324 -21 | +21 | 22 | crypt.crypt("test", salt=crypt.METHOD_CRYPT) | S324.py:22:26: S324 Probable use of insecure hash functions in `crypt`: `crypt.METHOD_CRYPT` | 20 | hashlib.new('sha1', usedforsecurity=True) -21 | +21 | 22 | crypt.crypt("test", salt=crypt.METHOD_CRYPT) | ^^^^^^^^^^^^^^^^^^ S324 23 | crypt.crypt("test", salt=crypt.METHOD_MD5) @@ -165,14 +164,14 @@ S324.py:25:21: S324 Probable use of insecure hash functions in `crypt`: `crypt.M 24 | crypt.crypt("test", salt=crypt.METHOD_BLOWFISH) 25 | crypt.crypt("test", crypt.METHOD_BLOWFISH) | ^^^^^^^^^^^^^^^^^^^^^ S324 -26 | +26 | 27 | crypt.mksalt(crypt.METHOD_CRYPT) | S324.py:27:14: S324 Probable use of insecure hash functions in `crypt`: `crypt.METHOD_CRYPT` | 25 | crypt.crypt("test", crypt.METHOD_BLOWFISH) -26 | +26 | 27 | crypt.mksalt(crypt.METHOD_CRYPT) | ^^^^^^^^^^^^^^^^^^ S324 28 | crypt.mksalt(crypt.METHOD_MD5) @@ -193,6 +192,6 @@ S324.py:29:14: S324 Probable use of insecure hash functions in `crypt`: `crypt.M 28 | crypt.mksalt(crypt.METHOD_MD5) 29 | crypt.mksalt(crypt.METHOD_BLOWFISH) | ^^^^^^^^^^^^^^^^^^^^^ S324 -30 | +30 | 31 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S501_S501.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S501_S501.py.snap index b8f363532c023..5c2e46e3d1696 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S501_S501.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S501_S501.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S501.py:5:47: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks | @@ -67,7 +66,7 @@ S501.py:17:48: S501 Probable use of `requests` call with `verify=False` disablin 16 | requests.head('https://gmail.com', timeout=30, verify=True) 17 | requests.head('https://gmail.com', timeout=30, verify=False) | ^^^^^^^^^^^^ S501 -18 | +18 | 19 | httpx.request('GET', 'https://gmail.com', verify=True) | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S502_S502.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S502_S502.py.snap index 3aa34a91df812..4087d85ab4148 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S502_S502.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S502_S502.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S502.py:6:13: S502 Call made with insecure SSL protocol: `PROTOCOL_SSLv3` | 4 | from OpenSSL.SSL import Context -5 | +5 | 6 | wrap_socket(ssl_version=ssl.PROTOCOL_SSLv3) # S502 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S502 7 | ssl.wrap_socket(ssl_version=ssl.PROTOCOL_TLSv1) # S502 @@ -66,6 +65,6 @@ S502.py:12:9: S502 Call made with insecure SSL protocol: `TLSv1_METHOD` 11 | Context(method=SSL.SSLv3_METHOD) # S502 12 | Context(method=SSL.TLSv1_METHOD) # S502 | ^^^^^^^^^^^^^^^^^^^^^^^ S502 -13 | +13 | 14 | wrap_socket(ssl_version=ssl.PROTOCOL_TLS_CLIENT) # OK | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S504_S504.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S504_S504.py.snap index 023976280eee3..faf1b6729a1af 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S504_S504.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S504_S504.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S504.py:4:1: S504 `ssl.wrap_socket` called without an `ssl_version`` | 2 | from ssl import wrap_socket -3 | +3 | 4 | ssl.wrap_socket() # S504 | ^^^^^^^^^^^^^^^^^ S504 5 | wrap_socket() # S504 diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S505_S505.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S505_S505.py.snap index 6b44dd23df49f..0177c4b1e4ca6 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S505_S505.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S505_S505.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S505.py:29:35: S505 DSA key sizes below 2048 bits are considered breakable | @@ -136,6 +135,6 @@ S505.py:44:28: S505 DSA key sizes below 2048 bits are considered breakable 43 | pycryptodomex_dsa.generate(2047) 44 | pycryptodomex_rsa.generate(2047) | ^^^^ S505 -45 | +45 | 46 | # Don't crash when the size is variable. | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S506_S506.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S506_S506.py.snap index 6d49ef426aa6a..e20574f58159f 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S506_S506.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S506_S506.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S506.py:10:9: S506 Probable use of unsafe `yaml.load`. Allows instantiation of arbitrary objects. Consider `yaml.safe_load`. | @@ -16,6 +15,6 @@ S506.py:24:24: S506 Probable use of unsafe loader `Loader` with `yaml.load`. All | 24 | yaml.load("{}", Loader=yaml.Loader) | ^^^^^^^^^^^ S506 -25 | +25 | 26 | # no issue should be found | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S507_S507.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S507_S507.py.snap index 791419044d6e1..0cf6adf52237c 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S507_S507.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S507_S507.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S507.py:15:40: S507 Paramiko call with policy set to automatically trust the unknown host key | @@ -76,6 +75,6 @@ S507.py:22:54: S507 Paramiko call with policy set to automatically trust the unk 21 | ssh_client.set_missing_host_key_policy(policy=WarningPolicy) 22 | ssh_client_from_paramiko.set_missing_host_key_policy(paramiko.AutoAddPolicy) | ^^^^^^^^^^^^^^^^^^^^^^ S507 -23 | +23 | 24 | # Unrelated | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S508_S508.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S508_S508.py.snap index f6d764b5acc56..34e169f4868bd 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S508_S508.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S508_S508.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S508.py:3:25: S508 The use of SNMPv1 and SNMPv2 is insecure. Use SNMPv3 if able. | 1 | from pysnmp.hlapi import CommunityData -2 | +2 | 3 | CommunityData("public", mpModel=0) # S508 | ^^^^^^^^^ S508 4 | CommunityData("public", mpModel=1) # S508 @@ -16,6 +15,6 @@ S508.py:4:25: S508 The use of SNMPv1 and SNMPv2 is insecure. Use SNMPv3 if able. 3 | CommunityData("public", mpModel=0) # S508 4 | CommunityData("public", mpModel=1) # S508 | ^^^^^^^^^ S508 -5 | +5 | 6 | CommunityData("public", mpModel=2) # OK | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S509_S509.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S509_S509.py.snap index 86a0e40c670aa..f676630f9151f 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S509_S509.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S509_S509.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S509.py:4:12: S509 You should not use SNMPv3 without encryption. `noAuthNoPriv` & `authNoPriv` is insecure. | @@ -14,6 +13,6 @@ S509.py:5:16: S509 You should not use SNMPv3 without encryption. `noAuthNoPriv` 4 | insecure = UsmUserData("securityName") # S509 5 | auth_no_priv = UsmUserData("securityName", "authName") # S509 | ^^^^^^^^^^^ S509 -6 | +6 | 7 | less_insecure = UsmUserData("securityName", "authName", "privName") # OK | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S601_S601.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S601_S601.py.snap index 411dbef599876..3479fa2b9e6cf 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S601_S601.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S601_S601.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S601.py:3:1: S601 Possible shell injection via Paramiko call; check inputs are properly sanitized | 1 | import paramiko -2 | +2 | 3 | paramiko.exec_command('something; really; unsafe') | ^^^^^^^^^^^^^^^^^^^^^ S601 | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S602_S602.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S602_S602.py.snap index b915b0214331f..54f3baf9f8b63 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S602_S602.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S602_S602.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S602.py:4:1: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` | @@ -46,7 +45,7 @@ S602.py:8:1: S602 `subprocess` call with `shell=True` seems safe, but may be cha 7 | check_output("true", shell=True) 8 | run("true", shell=True) | ^^^ S602 - 9 | + 9 | 10 | # Check values that truthy values are treated as true. | @@ -84,7 +83,7 @@ S602.py:14:1: S602 `subprocess` call with truthy `shell` seems safe, but may be 13 | Popen("true", shell={1: 1}) 14 | Popen("true", shell=(1,)) | ^^^^^ S602 -15 | +15 | 16 | # Check command argument looks unsafe. | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S603_S603.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S603_S603.py.snap index 12a354c8a4398..dba0c9317442a 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S603_S603.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S603_S603.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S603.py:4:1: S603 `subprocess` call: check for execution of untrusted input | @@ -46,7 +45,7 @@ S603.py:8:1: S603 `subprocess` call: check for execution of untrusted input 7 | check_output("true", shell=False) 8 | run("true", shell=False) | ^^^ S603 - 9 | + 9 | 10 | # Values that falsey values are treated as false. | @@ -84,7 +83,7 @@ S603.py:14:1: S603 `subprocess` call: check for execution of untrusted input 13 | Popen("true", shell={}) 14 | Popen("true", shell=None) | ^^^^^ S603 -15 | +15 | 16 | # Unknown values are treated as falsey. | @@ -93,7 +92,7 @@ S603.py:17:1: S603 `subprocess` call: check for execution of untrusted input 16 | # Unknown values are treated as falsey. 17 | Popen("true", shell=True if True else False) | ^^^^^ S603 -18 | +18 | 19 | # No value is also caught. | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S607_S607.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S607_S607.py.snap index 599f4b465a101..ca8c9abd8416e 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S607_S607.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S607_S607.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S607.py:9:11: S607 Starting a process with a partial executable path | @@ -217,6 +216,6 @@ S607.py:37:14: S607 Starting a process with a partial executable path 36 | os.spawnvpe("true") 37 | os.startfile("true") | ^^^^^^ S607 -38 | +38 | 39 | # Check it does not fail for full paths. | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S609_S609.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S609_S609.py.snap index 7de88902d2bdd..2482ce3206c04 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S609_S609.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S609_S609.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S609.py:4:10: S609 Possible wildcard injection in call due to `*` usage | 2 | import subprocess -3 | +3 | 4 | os.popen("chmod +w foo*") | ^^^^^^^^^^^^^^^ S609 5 | subprocess.Popen("/bin/chown root: *", shell=True) diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S610_S610.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S610_S610.py.snap index f3be9d306b299..4a8bf84b1a97f 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S610_S610.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S610_S610.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S610.py:4:44: S610 Use of Django `extra` can lead to SQL injection vulnerabilities | @@ -56,7 +55,7 @@ S610.py:9:44: S610 Use of Django `extra` can lead to SQL injection vulnerabiliti 8 | User.objects.filter(username='admin').extra(where=['%secure' % 'nos']) 9 | User.objects.filter(username='admin').extra(where=['{}secure'.format('no')]) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S610 -10 | +10 | 11 | query = '"username") AS "username", * FROM "auth_user" WHERE 1=1 OR "username"=? --' | @@ -65,7 +64,7 @@ S610.py:12:44: S610 Use of Django `extra` can lead to SQL injection vulnerabilit 11 | query = '"username") AS "username", * FROM "auth_user" WHERE 1=1 OR "username"=? --' 12 | User.objects.filter(username='admin').extra(select={'test': query}) | ^^^^^^^^^^^^^^^^^^^^^^^^ S610 -13 | +13 | 14 | where_var = ['1=1) OR 1=1 AND (1=1'] | @@ -74,7 +73,7 @@ S610.py:15:44: S610 Use of Django `extra` can lead to SQL injection vulnerabilit 14 | where_var = ['1=1) OR 1=1 AND (1=1'] 15 | User.objects.filter(username='admin').extra(where=where_var) | ^^^^^^^^^^^^^^^^^ S610 -16 | +16 | 17 | where_str = '1=1) OR 1=1 AND (1=1' | @@ -83,7 +82,7 @@ S610.py:18:44: S610 Use of Django `extra` can lead to SQL injection vulnerabilit 17 | where_str = '1=1) OR 1=1 AND (1=1' 18 | User.objects.filter(username='admin').extra(where=[where_str]) | ^^^^^^^^^^^^^^^^^^^ S610 -19 | +19 | 20 | tables_var = ['django_content_type" WHERE "auth_user"."username"="admin'] | @@ -92,7 +91,7 @@ S610.py:21:25: S610 Use of Django `extra` can lead to SQL injection vulnerabilit 20 | tables_var = ['django_content_type" WHERE "auth_user"."username"="admin'] 21 | User.objects.all().extra(tables=tables_var).distinct() | ^^^^^^^^^^^^^^^^^^^ S610 -22 | +22 | 23 | tables_str = 'django_content_type" WHERE "auth_user"."username"="admin' | @@ -101,6 +100,6 @@ S610.py:24:25: S610 Use of Django `extra` can lead to SQL injection vulnerabilit 23 | tables_str = 'django_content_type" WHERE "auth_user"."username"="admin' 24 | User.objects.all().extra(tables=[tables_str]).distinct() | ^^^^^^^^^^^^^^^^^^^^^ S610 -25 | +25 | 26 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S612_S612.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S612_S612.py.snap index ab65d212524fb..f7a16b78e4c1c 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S612_S612.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S612_S612.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S612.py:3:5: S612 Use of insecure `logging.config.listen` detected | 1 | import logging.config -2 | +2 | 3 | t = logging.config.listen(9999) | ^^^^^^^^^^^^^^^^^^^^^ S612 -4 | +4 | 5 | def verify_func(): | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S701_S701.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S701_S701.py.snap index 4f83f30a53d95..61b156e89196a 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S701_S701.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S701_S701.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S701.py:9:57: S701 Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function. | @@ -28,14 +27,14 @@ S701.py:13:13: S701 Using jinja2 templates with `autoescape=False` is dangerous 12 | load=templateLoader, 13 | autoescape=False) # S701 | ^^^^^^^^^^^^^^^^ S701 -14 | +14 | 15 | Environment(loader=templateLoader, # S701 | S701.py:15:1: S701 By default, jinja2 sets `autoescape` to `False`. Consider using `autoescape=True` or the `select_autoescape` function to mitigate XSS vulnerabilities. | 13 | autoescape=False) # S701 -14 | +14 | 15 | Environment(loader=templateLoader, # S701 | ^^^^^^^^^^^ S701 16 | load=templateLoader) diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S702_S702.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S702_S702.py.snap index 6d32769376ba4..3297e5af7e831 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S702_S702.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S702_S702.py.snap @@ -1,19 +1,18 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S702.py:6:1: S702 Mako templates allow HTML and JavaScript rendering by default and are inherently open to XSS attacks | 6 | Template("hello") | ^^^^^^^^ S702 -7 | +7 | 8 | mako.template.Template("hern") | S702.py:8:1: S702 Mako templates allow HTML and JavaScript rendering by default and are inherently open to XSS attacks | 6 | Template("hello") -7 | +7 | 8 | mako.template.Template("hern") | ^^^^^^^^^^^^^^^^^^^^^^ S702 9 | template.Template("hern") diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B003_B003.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B003_B003.py.snap index f1360b8ab30f8..3220d7235393a 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B003_B003.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B003_B003.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B003.py:9:1: B003 Assigning to `os.environ` doesn't clear the environment | 7 | from os import environ - 8 | + 8 | 9 | os.environ = {} | ^^^^^^^^^^ B003 10 | environ = {} # that's fine, assigning a new meaning to the module-level name diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B004_B004.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B004_B004.py.snap index 9513c0cf35b37..2d67212e68d25 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B004_B004.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B004_B004.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B004.py:3:8: B004 [*] Using `hasattr(x, "__call__")` to test if x is callable is unreliable. Use `callable(x)` for consistent results. | @@ -66,7 +65,7 @@ B004.py:14:8: B004 Using `hasattr(x, "__call__")` to test if x is callable is un B004.py:24:8: B004 [*] Using `hasattr(x, "__call__")` to test if x is callable is unreliable. Use `callable(x)` for consistent results. | 22 | return True -23 | +23 | 24 | if hasattr(o, "__call__"): | ^^^^^^^^^^^^^^^^^^^^^^ B004 25 | print("STILL a bug!") diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B005_B005.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B005_B005.py.snap index 66334d60f03fe..9291a453fab72 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B005_B005.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B005_B005.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B005.py:4:1: B005 Using `.strip()` with multi-character strings is misleading | @@ -78,6 +77,6 @@ B005.py:24:1: B005 Using `.strip()` with multi-character strings is misleading 23 | s.strip("\ufeff") # no warning 24 | s.strip("\u0074\u0065\u0073\u0074") # warning | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B005 -25 | +25 | 26 | from somewhere import other_type, strip | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_1.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_1.py.snap index bf28fec160d5f..a14c6205fc5ce 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_1.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B006_1.py:3:22: B006 [*] Do not use mutable data structures for argument defaults | 1 | # Docstring followed by a newline -2 | +2 | 3 | def foobar(foor, bar={}): | ^^ B006 4 | """ diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_2.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_2.py.snap index 09257a8d9208f..6148acae1a9e0 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_2.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B006_2.py:4:22: B006 [*] Do not use mutable data structures for argument defaults | 2 | # Regression test for https://github.com/astral-sh/ruff/issues/7155 -3 | +3 | 4 | def foobar(foor, bar={}): | ^^ B006 5 | """ diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_6.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_6.py.snap index 3a1addc5afdfc..45040e91fb9e7 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_6.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_6.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B006_6.py:4:22: B006 [*] Do not use mutable data structures for argument defaults | 2 | # Same as B006_2.py, but import instead of docstring -3 | +3 | 4 | def foobar(foor, bar={}): | ^^ B006 5 | import os diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_7.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_7.py.snap index 3cd491b156bba..3e00a26e6f509 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_7.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_7.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B006_7.py:4:22: B006 [*] Do not use mutable data structures for argument defaults | 2 | # Same as B006_3.py, but import instead of docstring -3 | +3 | 4 | def foobar(foor, bar={}): | ^^ B006 5 | import os diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_B008.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_B008.py.snap index c93320a973707..1fa6c1c985931 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_B008.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_B008.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B006_B008.py:63:25: B006 [*] Do not use mutable data structures for argument defaults | @@ -62,7 +61,7 @@ B006_B008.py:77:31: B006 [*] Do not use mutable data structures for argument def | 77 | def multiline_arg_wrong(value={ | _______________________________^ -78 | | +78 | | 79 | | }): | |_^ B006 80 | ... @@ -84,7 +83,7 @@ B006_B008.py:77:31: B006 [*] Do not use mutable data structures for argument def B006_B008.py:82:36: B006 Do not use mutable data structures for argument defaults | 80 | ... -81 | +81 | 82 | def single_line_func_wrong(value = {}): ... | ^^ B006 | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B007_B007.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B007_B007.py.snap index 12d3aaa584206..ea5052cf82934 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B007_B007.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B007_B007.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B007.py:6:5: B007 Loop control variable `i` not used within loop body | 4 | print(i) # name no longer defined on Python 3; no warning yet -5 | +5 | 6 | for i in range(10): # name not used within the loop; B007 | ^ B007 7 | print(10) @@ -71,7 +70,7 @@ B007.py:34:10: B007 Loop control variable `bar` may not be used within loop body B007.py:38:10: B007 Loop control variable `bar` may not be used within loop body | 36 | print(FMT.format(**locals())) -37 | +37 | 38 | for foo, bar in [(1, 2)]: | ^^^ B007 39 | if foo: @@ -82,7 +81,7 @@ B007.py:38:10: B007 Loop control variable `bar` may not be used within loop body B007.py:42:10: B007 Loop control variable `bar` may not be used within loop body | 40 | print(FMT.format(**globals())) -41 | +41 | 42 | for foo, bar in [(1, 2)]: | ^^^ B007 43 | if foo: @@ -93,7 +92,7 @@ B007.py:42:10: B007 Loop control variable `bar` may not be used within loop body B007.py:46:10: B007 Loop control variable `bar` may not be used within loop body | 44 | print(FMT.format(**vars())) -45 | +45 | 46 | for foo, bar in [(1, 2)]: | ^^^ B007 47 | print(FMT.format(foo=foo, bar=eval("bar"))) diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B009_B009_B010.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B009_B009_B010.py.snap index 5a74d284b8a83..5748ea4eb7612 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B009_B009_B010.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B009_B009_B010.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B009_B010.py:19:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. | @@ -322,7 +321,7 @@ B009_B010.py:58:8: B009 [*] Do not call `getattr` with a constant attribute valu 57 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458885 58 | assert getattr(func, '_rpc')is True | ^^^^^^^^^^^^^^^^^^^^^ B009 -59 | +59 | 60 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1732387247 | = help: Replace `getattr` with attribute access @@ -343,7 +342,7 @@ B009_B010.py:65:1: B009 [*] Do not call `getattr` with a constant attribute valu 65 | / getattr(self. 66 | | registration.registry, '__name__') | |_____________________________________^ B009 -67 | +67 | 68 | import builtins | = help: Replace `getattr` with attribute access diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B010_B009_B010.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B010_B009_B010.py.snap index a7f67bd8d88e8..42a169cb1b2e0 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B010_B009_B010.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B010_B009_B010.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B009_B010.py:50:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. | @@ -111,7 +110,7 @@ B009_B010.py:55:1: B010 [*] Do not call `setattr` with a constant attribute valu 54 | setattr(foo, r"abc123", None) 55 | setattr(foo.bar, r"baz", None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010 -56 | +56 | 57 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458885 | = help: Replace `setattr` with assignment diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B012_B012.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B012_B012.py.snap index 997e6b1bb9c0f..5bbd36c330033 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B012_B012.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B012_B012.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B012.py:5:9: B012 `return` inside `finally` blocks cause exceptions to be silenced | @@ -44,7 +43,7 @@ B012.py:44:21: B012 `return` inside `finally` blocks cause exceptions to be sile 43 | finally: 44 | return # warning | ^^^^^^ B012 -45 | +45 | 46 | finally: | @@ -54,7 +53,7 @@ B012.py:66:13: B012 `break` inside `finally` blocks cause exceptions to be silen 65 | finally: 66 | break # warning | ^^^^^ B012 -67 | +67 | 68 | def j(): | @@ -64,7 +63,7 @@ B012.py:78:13: B012 `continue` inside `finally` blocks cause exceptions to be si 77 | finally: 78 | continue # warning | ^^^^^^^^ B012 -79 | +79 | 80 | def j(): | @@ -82,7 +81,7 @@ B012.py:101:9: B012 `continue` inside `finally` blocks cause exceptions to be si 100 | finally: 101 | continue # warning | ^^^^^^^^ B012 -102 | +102 | 103 | while True: | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B015_B015.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B015_B015.py.snap index 29d06e7de2f01..1fe419d2fd6d6 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B015_B015.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B015_B015.py.snap @@ -1,21 +1,20 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B015.py:3:1: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. | 1 | assert 1 == 1 -2 | +2 | 3 | 1 == 1 | ^^^^^^ B015 -4 | +4 | 5 | assert 1 in (1, 2) | B015.py:7:1: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. | 5 | assert 1 in (1, 2) -6 | +6 | 7 | 1 in (1, 2) | ^^^^^^^^^^^ B015 | @@ -23,7 +22,7 @@ B015.py:7:1: B015 Pointless comparison. Did you mean to assign a value? Otherwis B015.py:17:5: B015 Pointless comparison at end of function scope. Did you mean to return the expression result? | 15 | assert 1 in (1, 2) -16 | +16 | 17 | 1 in (1, 2) | ^^^^^^^^^^^ B015 | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B016_B016.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B016_B016.py.snap index 51d3ca8098ea9..1a999923dbb57 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B016_B016.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B016_B016.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B016.py:6:7: B016 Cannot raise a literal. Did you intend to return it or raise an Exception? | 4 | """ -5 | +5 | 6 | raise False | ^^^^^ B016 7 | raise 1 diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B017_B017.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B017_B017.py.snap index 5b578e1f50669..bbee0c1d9158c 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B017_B017.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B017_B017.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B017.py:23:14: B017 Do not assert blind exception: `Exception` | @@ -30,7 +29,7 @@ B017.py:45:10: B017 Do not assert blind exception: `Exception` B017.py:48:10: B017 Do not assert blind exception: `Exception` | 46 | raise ValueError("Hello") -47 | +47 | 48 | with pytest.raises(Exception), pytest.raises(ValueError): | ^^^^^^^^^^^^^^^^^^^^^^^^ B017 49 | raise ValueError("Hello") @@ -39,7 +38,7 @@ B017.py:48:10: B017 Do not assert blind exception: `Exception` B017.py:57:36: B017 Do not assert blind exception: `Exception` | 55 | raise ValueError("This is also fine") -56 | +56 | 57 | with contextlib.nullcontext(), pytest.raises(Exception): | ^^^^^^^^^^^^^^^^^^^^^^^^ B017 58 | raise ValueError("Multiple context managers") diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B019_B019.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B019_B019.py.snap index c1652842359c7..dfba309de447e 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B019_B019.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B019_B019.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B019.py:78:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks | @@ -14,7 +13,7 @@ B019.py:78:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods B019.py:82:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks | 80 | ... -81 | +81 | 82 | @cache | ^^^^^^ B019 83 | def another_cached_instance_method(self, y): @@ -24,7 +23,7 @@ B019.py:82:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods B019.py:86:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks | 84 | ... -85 | +85 | 86 | @functools.cache() | ^^^^^^^^^^^^^^^^^^ B019 87 | def called_cached_instance_method(self, y): @@ -34,7 +33,7 @@ B019.py:86:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods B019.py:90:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks | 88 | ... -89 | +89 | 90 | @cache() | ^^^^^^^^ B019 91 | def another_called_cached_instance_method(self, y): @@ -44,7 +43,7 @@ B019.py:90:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods B019.py:94:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks | 92 | ... -93 | +93 | 94 | @functools.lru_cache | ^^^^^^^^^^^^^^^^^^^^ B019 95 | def lru_cached_instance_method(self, y): @@ -54,7 +53,7 @@ B019.py:94:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods B019.py:98:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks | 96 | ... - 97 | + 97 | 98 | @lru_cache | ^^^^^^^^^^ B019 99 | def another_lru_cached_instance_method(self, y): @@ -64,7 +63,7 @@ B019.py:98:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods B019.py:102:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks | 100 | ... -101 | +101 | 102 | @functools.lru_cache() | ^^^^^^^^^^^^^^^^^^^^^^ B019 103 | def called_lru_cached_instance_method(self, y): @@ -74,7 +73,7 @@ B019.py:102:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods B019.py:106:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks | 104 | ... -105 | +105 | 106 | @lru_cache() | ^^^^^^^^^^^^ B019 107 | def another_called_lru_cached_instance_method(self, y): diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B020_B020.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B020_B020.py.snap index 8fb15a2263a07..b734156c7292e 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B020_B020.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B020_B020.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B020.py:8:5: B020 Loop control variable `items` overrides iterable it iterates | 6 | items = [1, 2, 3] -7 | +7 | 8 | for items in items: | ^^^^^ B020 9 | print(items) @@ -14,7 +13,7 @@ B020.py:8:5: B020 Loop control variable `items` overrides iterable it iterates B020.py:21:10: B020 Loop control variable `values` overrides iterable it iterates | 19 | print(f"{key}, {value}") -20 | +20 | 21 | for key, values in values.items(): | ^^^^^^ B020 22 | print(f"{key}, {values}") diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B021_B021.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B021_B021.py.snap index 6468cffbd7f77..32c3200f25b90 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B021_B021.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B021_B021.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B021.py:1:1: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. | @@ -9,7 +8,7 @@ B021.py:1:1: B021 f-string used as docstring. Python will interpret this as a jo 3 | | B021 - on lines 14, 22, 30, 38, 46, 54, 62, 70, 73 4 | | """ | |___^ B021 -5 | +5 | 6 | VARIABLE = "world" | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B022_B022.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B022_B022.py.snap index 28dadc3836106..d5b49021397a6 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B022_B022.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B022_B022.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B022.py:9:6: B022 No arguments passed to `contextlib.suppress`. No exceptions will be suppressed and therefore this context manager is redundant | 7 | from contextlib import suppress - 8 | + 8 | 9 | with contextlib.suppress(): | ^^^^^^^^^^^^^^^^^^^^^ B022 10 | raise ValueError @@ -14,7 +13,7 @@ B022.py:9:6: B022 No arguments passed to `contextlib.suppress`. No exceptions wi B022.py:12:6: B022 No arguments passed to `contextlib.suppress`. No exceptions will be suppressed and therefore this context manager is redundant | 10 | raise ValueError -11 | +11 | 12 | with suppress(): | ^^^^^^^^^^ B022 13 | raise ValueError diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B023_B023.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B023_B023.py.snap index 500183278dc58..0ee9c539387dc 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B023_B023.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B023_B023.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B023.py:12:30: B023 Function definition does not bind loop variable `x` | @@ -17,7 +16,7 @@ B023.py:13:30: B023 Function definition does not bind loop variable `y` 12 | functions.append(lambda: x) 13 | functions.append(lambda: y) # not just the loop var | ^ B023 -14 | +14 | 15 | def f_bad_1(): | @@ -26,7 +25,7 @@ B023.py:16:16: B023 Function definition does not bind loop variable `x` 15 | def f_bad_1(): 16 | return x | ^ B023 -17 | +17 | 18 | # Actually OK | @@ -72,14 +71,14 @@ B023.py:40:34: B023 Function definition does not bind loop variable `x` 39 | async for x in pointless_async_iterable(): 40 | functions.append(lambda: x) # error | ^ B023 -41 | +41 | 42 | [lambda: x async for x in pointless_async_iterable()] # error | B023.py:42:14: B023 Function definition does not bind loop variable `x` | 40 | functions.append(lambda: x) # error -41 | +41 | 42 | [lambda: x async for x in pointless_async_iterable()] # error | ^ B023 | @@ -146,7 +145,7 @@ B023.py:68:10: B023 Function definition does not bind loop variable `l` 67 | j = None # OK because it's an assignment 68 | [l for k in range(2)] # error for l, not for k | ^ B023 -69 | +69 | 70 | assert a and functions | @@ -202,7 +201,7 @@ B023.py:121:37: B023 Function definition does not bind loop variable `x` 120 | list(filter(bool, [None, lambda: x])) 121 | all(reduce(bool, [None, lambda: x])) | ^ B023 -122 | +122 | 123 | # But all these should be OK: | @@ -211,7 +210,7 @@ B023.py:171:29: B023 Function definition does not bind loop variable `name` 170 | if foo(name): 171 | return [lambda: name] # known false alarm | ^^^^ B023 -172 | +172 | 173 | if False: | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B028_B028.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B028_B028.py.snap index f8d765b4e08c6..cf6ec733783d7 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B028_B028.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B028_B028.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B028.py:8:1: B028 [*] No explicit `stacklevel` keyword argument found | 6 | """ - 7 | + 7 | 8 | warnings.warn("test", DeprecationWarning) | ^^^^^^^^^^^^^ B028 9 | warnings.warn("test", DeprecationWarning, source=None) @@ -47,7 +46,7 @@ B028.py:9:1: B028 [*] No explicit `stacklevel` keyword argument found B028.py:22:1: B028 [*] No explicit `stacklevel` keyword argument found | 20 | warnings.warn(*args, **kwargs) -21 | +21 | 22 | warnings.warn( | ^^^^^^^^^^^^^ B028 23 | "test", diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B029_B029.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B029_B029.py.snap index 57ecefcc16353..776d2e3882d67 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B029_B029.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B029_B029.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B029.py:8:1: B029 Using `except ():` with an empty tuple does not catch anything; add exceptions to handle | @@ -9,7 +8,7 @@ B029.py:8:1: B029 Using `except ():` with an empty tuple does not catch anything 8 | / except (): 9 | | pass | |________^ B029 -10 | +10 | 11 | try: | @@ -20,7 +19,7 @@ B029.py:13:1: B029 Using `except ():` with an empty tuple does not catch anythin 13 | / except () as e: 14 | | pass | |________^ B029 -15 | +15 | 16 | try: | @@ -31,7 +30,7 @@ B029.py:18:1: B029 Using `except* ():` with an empty tuple does not catch anythi 18 | / except* (): 19 | | pass | |________^ B029 -20 | +20 | 21 | try: | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B031_B031.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B031_B031.py.snap index 57ca85a502d22..b13db50fcda64 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B031_B031.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B031_B031.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B031.py:27:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage | @@ -18,7 +17,7 @@ B031.py:29:33: B031 Using the generator returned from `itertools.groupby()` more 28 | # We're outside the nested loop and used the group again. 29 | collect_shop_items(shopper, section_items) # B031 | ^^^^^^^^^^^^^ B031 -30 | +30 | 31 | for _section, section_items in groupby(items, key=lambda p: p[1]): | @@ -45,7 +44,7 @@ B031.py:46:29: B031 Using the generator returned from `itertools.groupby()` more 45 | for _section, section_items in groupby(items, key=lambda p: p[1]): 46 | collection.append([list(section_items) for _ in range(3)]) # B031 | ^^^^^^^^^^^^^ B031 -47 | +47 | 48 | unique_items = set() | @@ -63,7 +62,7 @@ B031.py:79:37: B031 Using the generator returned from `itertools.groupby()` more 78 | for shopper in shoppers: 79 | collect_shop_items(shopper, section_items) # B031 | ^^^^^^^^^^^^^ B031 -80 | +80 | 81 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): | @@ -72,7 +71,7 @@ B031.py:82:38: B031 Using the generator returned from `itertools.groupby()` more 81 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): 82 | _ = [collect_shop_items(shopper, section_items) for shopper in shoppers] # B031 | ^^^^^^^^^^^^^ B031 -83 | +83 | 84 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): | @@ -82,7 +81,7 @@ B031.py:94:65: B031 Using the generator returned from `itertools.groupby()` more 93 | # The iterator is being used for the second time. 94 | _ = [(item1, item2) for item1 in section_items for item2 in section_items] # B031 | ^^^^^^^^^^^^^ B031 -95 | +95 | 96 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): | @@ -92,7 +91,7 @@ B031.py:101:37: B031 Using the generator returned from `itertools.groupby()` mor 100 | collect_shop_items(shopper, section_items) 101 | collect_shop_items(shopper, section_items) # B031 | ^^^^^^^^^^^^^ B031 -102 | +102 | 103 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): | @@ -152,7 +151,7 @@ B031.py:126:33: B031 Using the generator returned from `itertools.groupby()` mor 125 | # Now, it should detect 126 | collect_shop_items(shopper, section_items) # B031 | ^^^^^^^^^^^^^ B031 -127 | +127 | 128 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): | @@ -192,7 +191,7 @@ B031.py:144:33: B031 Using the generator returned from `itertools.groupby()` mor 143 | # Now, it should detect 144 | collect_shop_items(shopper, section_items) # B031 | ^^^^^^^^^^^^^ B031 -145 | +145 | 146 | for group in groupby(items, key=lambda p: p[1]): | @@ -211,7 +210,7 @@ B031.py:210:37: B031 Using the generator returned from `itertools.groupby()` mor 209 | collect_shop_items(shopper, section_items) 210 | collect_shop_items(shopper, section_items) | ^^^^^^^^^^^^^ B031 -211 | +211 | 212 | # Should trigger, since only one branch has a return statement. | @@ -221,6 +220,6 @@ B031.py:219:33: B031 Using the generator returned from `itertools.groupby()` mor 218 | collect_shop_items(shopper, section_items) 219 | collect_shop_items(shopper, section_items) # B031 | ^^^^^^^^^^^^^ B031 -220 | +220 | 221 | # Let's redefine the `groupby` function to make sure we pick up the correct one. | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B032_B032.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B032_B032.py.snap index 28266195745ae..dd53337080261 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B032_B032.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B032_B032.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B032.py:9:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? | 7 | dct = {"a": 1} - 8 | + 8 | 9 | dct["b"]: 2 | ^^^^^^^^^^^ B032 10 | dct.b: 2 @@ -16,14 +15,14 @@ B032.py:10:1: B032 Possible unintentional type annotation (using `:`). Did you m 9 | dct["b"]: 2 10 | dct.b: 2 | ^^^^^^^^ B032 -11 | +11 | 12 | dct["b"]: "test" | B032.py:12:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? | 10 | dct.b: 2 -11 | +11 | 12 | dct["b"]: "test" | ^^^^^^^^^^^^^^^^ B032 13 | dct.b: "test" @@ -34,7 +33,7 @@ B032.py:13:1: B032 Possible unintentional type annotation (using `:`). Did you m 12 | dct["b"]: "test" 13 | dct.b: "test" | ^^^^^^^^^^^^^ B032 -14 | +14 | 15 | test = "test" | @@ -72,6 +71,6 @@ B032.py:19:1: B032 Possible unintentional type annotation (using `:`). Did you m 18 | dct.b: test 19 | dct.b: test.lower() | ^^^^^^^^^^^^^^^^^^^ B032 -20 | +20 | 21 | # Do not flag below | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B033_B033.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B033_B033.py.snap index db3e493b6835a..d04d48aa93da9 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B033_B033.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B033_B033.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B033.py:4:35: B033 [*] Sets should not contain duplicate item `"value1"` | @@ -174,7 +173,7 @@ B033.py:22:28: B033 [*] Sets should not contain duplicate items, but `False` and 21 | } 22 | incorrect_set = {False, 1, 0} | ^ B033 -23 | +23 | 24 | ### | = help: Remove duplicate item diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B034_B034.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B034_B034.py.snap index 066befba4cea1..c92b98b7d5c79 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B034_B034.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B034_B034.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B034.py:5:1: B034 `re.sub` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions | @@ -96,6 +95,6 @@ B034.py:14:1: B034 `re.sub` should pass `count` and `flags` as keyword arguments 13 | re.split(" ", "a a a a", 2, re.I) 14 | sub("a", "b", "aaa", re.IGNORECASE) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 -15 | +15 | 16 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B039_B039.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B039_B039.py.snap index 429f011542c6e..8b7b9add10f4f 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B039_B039.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B039_B039.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B039.py:21:26: B039 Do not use mutable data structures for `ContextVar` defaults | @@ -116,7 +115,7 @@ B039.py:31:36: B039 Do not use mutable data structures for `ContextVar` defaults 30 | ContextVar("cv", default=set[str]()) 31 | ContextVar[set[str]]("cv", default=set[str]()) | ^^^^^^^^^^ B039 -32 | +32 | 33 | def bar() -> list[int]: | = help: Replace with `None`; initialize with `.set()`` @@ -124,7 +123,7 @@ B039.py:31:36: B039 Do not use mutable data structures for `ContextVar` defaults B039.py:36:26: B039 Do not use mutable data structures for `ContextVar` defaults | 34 | return [1, 2, 3] -35 | +35 | 36 | ContextVar("cv", default=bar()) | ^^^^^ B039 37 | ContextVar("cv", default=time.time()) @@ -136,7 +135,7 @@ B039.py:37:26: B039 Do not use mutable data structures for `ContextVar` defaults 36 | ContextVar("cv", default=bar()) 37 | ContextVar("cv", default=time.time()) | ^^^^^^^^^^^ B039 -38 | +38 | 39 | def baz(): ... | = help: Replace with `None`; initialize with `.set()`` diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B901_B901.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B901_B901.py.snap index 7538d0c1a405a..8d98e5fcd4fe1 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B901_B901.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B901_B901.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B901.py:9:9: B901 Using `yield` and `return {value}` in a generator function can lead to confusing behavior | @@ -8,7 +7,7 @@ B901.py:9:9: B901 Using `yield` and `return {value}` in a generator function can 8 | if True: 9 | return [1, 2, 3] | ^^^^^^^^^^^^^^^^ B901 -10 | +10 | 11 | yield 3 | @@ -17,6 +16,6 @@ B901.py:36:5: B901 Using `yield` and `return {value}` in a generator function ca 35 | def broken2(): 36 | return [3, 2, 1] | ^^^^^^^^^^^^^^^^ B901 -37 | +37 | 38 | yield from not_broken() | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B903_class_as_data_structure.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B903_class_as_data_structure.py.snap index eea9b90dd5bfe..0d3826aea63ce 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B903_class_as_data_structure.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B903_class_as_data_structure.py.snap @@ -13,27 +13,27 @@ class_as_data_structure.py:6:1: B903 Class could be dataclass or namedtuple class_as_data_structure.py:40:1: B903 Class could be dataclass or namedtuple | 38 | ... -39 | +39 | 40 | / class C: # B903 41 | | c: int 42 | | def __init__(self,d:list): 43 | | self.d = d | |__________________^ B903 -44 | +44 | 45 | class D: # B903 | class_as_data_structure.py:45:1: B903 Class could be dataclass or namedtuple | 43 | self.d = d -44 | +44 | 45 | / class D: # B903 46 | | """This class has a docstring.""" 47 | | # this next method is an init 48 | | def __init__(self,e:dict): 49 | | self.e = e | |__________________^ B903 -50 | +50 | 51 | # <--- begin flake8-bugbear tests below | @@ -41,7 +41,7 @@ class_as_data_structure.py:63:1: B903 Class could be dataclass or namedtuple | 63 | / class NoWarningsClassAttributes: 64 | | spam = "ham" -65 | | +65 | | 66 | | def __init__(self, foo:int, bar:list): 67 | | self.foo = foo 68 | | self.bar = bar @@ -61,11 +61,11 @@ class_as_data_structure.py:91:1: B903 Class could be dataclass or namedtuple | 91 | / class WarningsWithDocstring: 92 | | """A docstring should not be an impediment to a warning""" -93 | | +93 | | 94 | | def __init__(self, foo:int, bar:list): 95 | | self.foo = foo 96 | | self.bar = bar | |______________________^ B903 -97 | +97 | 98 | # <-- end flake8-bugbear tests | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B904_B904.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B904_B904.py.snap index dc4604c1bf312..1d7390ce045eb 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B904_B904.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B904_B904.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B904.py:10:9: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling | @@ -66,7 +65,7 @@ B904.py:73:13: B904 Within an `except` clause, raise exceptions with `raise ... 72 | case 0: 73 | raise RuntimeError("boom!") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B904 -74 | +74 | 75 | try: | @@ -86,7 +85,7 @@ B904.py:81:9: B904 Within an `except*` clause, raise exceptions with `raise ... 80 | else: 81 | raise RuntimeError("bang!") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B904 -82 | +82 | 83 | try: | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B905.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B905.py.snap index 899a911b38d22..4628deaeeca45 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B905.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B905.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B905.py:4:1: B905 [*] `zip()` without an explicit `strict=` parameter | @@ -132,7 +131,7 @@ B905.py:9:1: B905 [*] `zip()` without an explicit `strict=` parameter 8 | zip(zip("a"), strict=False) 9 | zip(zip("a", strict=True)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ B905 -10 | +10 | 11 | # OK | = help: Add explicit value for parameter `strict=` @@ -172,7 +171,7 @@ B905.py:25:1: B905 [*] `zip()` without an explicit `strict=` parameter 24 | zip([1, 2, 3], repeat(1, 1)) 25 | zip([1, 2, 3], repeat(1, times=4)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B905 -26 | +26 | 27 | import builtins | = help: Add explicit value for parameter `strict=` diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B909_B909.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B909_B909.py.snap index 076f46987f408..c7385dec29dea 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B909_B909.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B909_B909.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B909.py:12:5: B909 Mutation to loop iterable `some_list` during iteration | @@ -97,7 +96,7 @@ B909.py:21:5: B909 Mutation to loop iterable `some_list` during iteration 20 | some_list.pop(1) 21 | some_list.pop() | ^^^^^^^^^^^^^ B909 -22 | +22 | 23 | # conditional break should error | @@ -136,7 +135,7 @@ B909.py:49:5: B909 Mutation to loop iterable `mydicts` during iteration 48 | mydicts.setdefault("foo", 1) 49 | mydicts.update({"foo": "bar"}) | ^^^^^^^^^^^^^^ B909 -50 | +50 | 51 | # no errors | @@ -195,7 +194,7 @@ B909.py:67:5: B909 Mutation to loop iterable `myset` during iteration 66 | myset.add(4) 67 | myset.discard(3) | ^^^^^^^^^^^^^ B909 -68 | +68 | 69 | # no errors | @@ -261,7 +260,7 @@ B909.py:97:5: B909 Mutation to loop iterable `foo` during iteration 96 | foo[1:2] = bar 97 | foo[1:2:3] = bar | ^^^^^^^^^^^^^^^^ B909 -98 | +98 | 99 | foo = {1, 2, 3} | @@ -318,7 +317,7 @@ B909.py:136:9: B909 Mutation to loop iterable `foo` during iteration 135 | else: 136 | foo.remove(1) | ^^^^^^^^^^ B909 -137 | +137 | 138 | # should error | @@ -366,7 +365,7 @@ B909.py:159:5: B909 Mutation to loop iterable `some_list` during iteration 158 | some_list.remove(elem) 159 | some_list.discard(elem) | ^^^^^^^^^^^^^^^^^ B909 -160 | +160 | 161 | # should not error | @@ -376,6 +375,6 @@ B909.py:167:5: B909 Mutation to loop iterable `some_list` during iteration 166 | for i, elem in enumerate(some_list): 167 | some_list.pop(0) | ^^^^^^^^^^^^^ B909 -168 | +168 | 169 | # should not error (list) | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B911_B911.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B911_B911.py.snap index 850a173070028..1ce2005be7fc9 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B911_B911.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B911_B911.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B911.py:5:1: B911 `itertools.batched()` without an explicit `strict` parameter | @@ -50,7 +49,7 @@ B911.py:9:1: B911 `itertools.batched()` without an explicit `strict` parameter 8 | batched((foo for foo in cycle())) 9 | batched(itertools.batched([1, 2, 3], strict=True)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B911 -10 | +10 | 11 | # Errors (limited iterators). | = help: Add an explicit `strict` parameter @@ -70,7 +69,7 @@ B911.py:13:1: B911 `itertools.batched()` without an explicit `strict` parameter 12 | batched(repeat(1, 1)) 13 | batched(repeat(1, times=4)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B911 -14 | +14 | 15 | # No fix | = help: Add an explicit `strict` parameter @@ -80,7 +79,7 @@ B911.py:16:1: B911 `itertools.batched()` without an explicit `strict` parameter 15 | # No fix 16 | batched([], **kwargs) | ^^^^^^^^^^^^^^^^^^^^^ B911 -17 | +17 | 18 | # No errors | = help: Add an explicit `strict` parameter @@ -133,7 +132,7 @@ B911.py:39:1: B911 `itertools.batched()` without an explicit `strict` parameter 38 | itertools.batched((foo for foo in cycle())) 39 | itertools.batched(itertools.batched([1, 2, 3], strict=True)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B911 -40 | +40 | 41 | # Errors (limited iterators). | = help: Add an explicit `strict` parameter @@ -153,7 +152,7 @@ B911.py:43:1: B911 `itertools.batched()` without an explicit `strict` parameter 42 | itertools.batched(repeat(1, 1)) 43 | itertools.batched(repeat(1, times=4)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B911 -44 | +44 | 45 | # No fix | = help: Add an explicit `strict` parameter @@ -163,7 +162,7 @@ B911.py:46:1: B911 `itertools.batched()` without an explicit `strict` parameter 45 | # No fix 46 | itertools.batched([], **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B911 -47 | +47 | 48 | # No errors | = help: Add an explicit `strict` parameter diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A001_A001.py.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A001_A001.py.snap index f427fe7ac281d..9baa2d027019d 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A001_A001.py.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A001_A001.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs -snapshot_kind: text --- A001.py:5:1: A001 Variable `print` is shadowing a Python builtin | 3 | from directory import new as dir -4 | +4 | 5 | print = 1 | ^^^^^ A001 6 | copyright: 'annotation' = 2 @@ -55,7 +54,7 @@ A001.py:9:1: A001 Variable `min` is shadowing a Python builtin 8 | float = object = 4 9 | min, max = 5, 6 | ^^^ A001 -10 | +10 | 11 | id = 4 | @@ -65,24 +64,24 @@ A001.py:9:6: A001 Variable `max` is shadowing a Python builtin 8 | float = object = 4 9 | min, max = 5, 6 | ^^^ A001 -10 | +10 | 11 | id = 4 | A001.py:11:1: A001 Variable `id` is shadowing a Python builtin | 9 | min, max = 5, 6 -10 | +10 | 11 | id = 4 | ^^ A001 -12 | +12 | 13 | def bytes(): | A001.py:13:5: A001 Variable `bytes` is shadowing a Python builtin | 11 | id = 4 -12 | +12 | 13 | def bytes(): | ^^^^^ A001 14 | pass @@ -91,7 +90,7 @@ A001.py:13:5: A001 Variable `bytes` is shadowing a Python builtin A001.py:16:7: A001 Variable `slice` is shadowing a Python builtin | 14 | pass -15 | +15 | 16 | class slice: | ^^^^^ A001 17 | pass @@ -109,7 +108,7 @@ A001.py:21:23: A001 Variable `ValueError` is shadowing a Python builtin A001.py:24:5: A001 Variable `memoryview` is shadowing a Python builtin | 22 | ... -23 | +23 | 24 | for memoryview, *bytearray in []: | ^^^^^^^^^^ A001 25 | pass @@ -118,7 +117,7 @@ A001.py:24:5: A001 Variable `memoryview` is shadowing a Python builtin A001.py:24:18: A001 Variable `bytearray` is shadowing a Python builtin | 22 | ... -23 | +23 | 24 | for memoryview, *bytearray in []: | ^^^^^^^^^ A001 25 | pass @@ -127,7 +126,7 @@ A001.py:24:18: A001 Variable `bytearray` is shadowing a Python builtin A001.py:27:22: A001 Variable `str` is shadowing a Python builtin | 25 | pass -26 | +26 | 27 | with open('file') as str, open('file2') as (all, any): | ^^^ A001 28 | pass @@ -136,7 +135,7 @@ A001.py:27:22: A001 Variable `str` is shadowing a Python builtin A001.py:27:45: A001 Variable `all` is shadowing a Python builtin | 25 | pass -26 | +26 | 27 | with open('file') as str, open('file2') as (all, any): | ^^^ A001 28 | pass @@ -145,7 +144,7 @@ A001.py:27:45: A001 Variable `all` is shadowing a Python builtin A001.py:27:50: A001 Variable `any` is shadowing a Python builtin | 25 | pass -26 | +26 | 27 | with open('file') as str, open('file2') as (all, any): | ^^^ A001 28 | pass @@ -154,7 +153,7 @@ A001.py:27:50: A001 Variable `any` is shadowing a Python builtin A001.py:30:8: A001 Variable `sum` is shadowing a Python builtin | 28 | pass -29 | +29 | 30 | [0 for sum in ()] | ^^^ A001 | diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A001_A001.py_builtins_ignorelist.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A001_A001.py_builtins_ignorelist.snap index 1f2554d95be3c..10d6961236874 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A001_A001.py_builtins_ignorelist.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A001_A001.py_builtins_ignorelist.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs -snapshot_kind: text --- A001.py:5:1: A001 Variable `print` is shadowing a Python builtin | 3 | from directory import new as dir -4 | +4 | 5 | print = 1 | ^^^^^ A001 6 | copyright: 'annotation' = 2 @@ -55,7 +54,7 @@ A001.py:9:1: A001 Variable `min` is shadowing a Python builtin 8 | float = object = 4 9 | min, max = 5, 6 | ^^^ A001 -10 | +10 | 11 | id = 4 | @@ -65,14 +64,14 @@ A001.py:9:6: A001 Variable `max` is shadowing a Python builtin 8 | float = object = 4 9 | min, max = 5, 6 | ^^^ A001 -10 | +10 | 11 | id = 4 | A001.py:13:5: A001 Variable `bytes` is shadowing a Python builtin | 11 | id = 4 -12 | +12 | 13 | def bytes(): | ^^^^^ A001 14 | pass @@ -81,7 +80,7 @@ A001.py:13:5: A001 Variable `bytes` is shadowing a Python builtin A001.py:16:7: A001 Variable `slice` is shadowing a Python builtin | 14 | pass -15 | +15 | 16 | class slice: | ^^^^^ A001 17 | pass @@ -99,7 +98,7 @@ A001.py:21:23: A001 Variable `ValueError` is shadowing a Python builtin A001.py:24:5: A001 Variable `memoryview` is shadowing a Python builtin | 22 | ... -23 | +23 | 24 | for memoryview, *bytearray in []: | ^^^^^^^^^^ A001 25 | pass @@ -108,7 +107,7 @@ A001.py:24:5: A001 Variable `memoryview` is shadowing a Python builtin A001.py:24:18: A001 Variable `bytearray` is shadowing a Python builtin | 22 | ... -23 | +23 | 24 | for memoryview, *bytearray in []: | ^^^^^^^^^ A001 25 | pass @@ -117,7 +116,7 @@ A001.py:24:18: A001 Variable `bytearray` is shadowing a Python builtin A001.py:27:22: A001 Variable `str` is shadowing a Python builtin | 25 | pass -26 | +26 | 27 | with open('file') as str, open('file2') as (all, any): | ^^^ A001 28 | pass @@ -126,7 +125,7 @@ A001.py:27:22: A001 Variable `str` is shadowing a Python builtin A001.py:27:45: A001 Variable `all` is shadowing a Python builtin | 25 | pass -26 | +26 | 27 | with open('file') as str, open('file2') as (all, any): | ^^^ A001 28 | pass @@ -135,7 +134,7 @@ A001.py:27:45: A001 Variable `all` is shadowing a Python builtin A001.py:27:50: A001 Variable `any` is shadowing a Python builtin | 25 | pass -26 | +26 | 27 | with open('file') as str, open('file2') as (all, any): | ^^^ A001 28 | pass @@ -144,7 +143,7 @@ A001.py:27:50: A001 Variable `any` is shadowing a Python builtin A001.py:30:8: A001 Variable `sum` is shadowing a Python builtin | 28 | pass -29 | +29 | 30 | [0 for sum in ()] | ^^^ A001 | diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A003_A003.py.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A003_A003.py.snap index 3edffeef745ee..082f3e3d5cd13 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A003_A003.py.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A003_A003.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs -snapshot_kind: text --- A003.py:17:31: A003 Python builtin is shadowed by method `str` from line 14 | 15 | pass -16 | +16 | 17 | def method_usage(self) -> str: | ^^^ A003 18 | pass @@ -14,7 +13,7 @@ A003.py:17:31: A003 Python builtin is shadowed by method `str` from line 14 A003.py:20:34: A003 Python builtin is shadowed by class attribute `id` from line 3 | 18 | pass -19 | +19 | 20 | def attribute_usage(self) -> id: | ^^ A003 21 | pass diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A003_A003.py_builtins_ignorelist.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A003_A003.py_builtins_ignorelist.snap index 484aa22247c4e..85f5360b4475c 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A003_A003.py_builtins_ignorelist.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A003_A003.py_builtins_ignorelist.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs -snapshot_kind: text --- A003.py:17:31: A003 Python builtin is shadowed by method `str` from line 14 | 15 | pass -16 | +16 | 17 | def method_usage(self) -> str: | ^^^ A003 18 | pass diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A004_A004.py.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A004_A004.py.snap index 4685dcb9a5648..6c8386ed148b5 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A004_A004.py.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A004_A004.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs -snapshot_kind: text --- A004.py:1:16: A004 Import `sum` is shadowing a Python builtin | @@ -53,7 +52,7 @@ A004.py:5:30: A004 Import `dir` is shadowing a Python builtin 4 | from some import input, exec 5 | from directory import new as dir | ^^^ A004 -6 | +6 | 7 | # See: https://github.com/astral-sh/ruff/issues/13037 | diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A004_A004.py_py38.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A004_A004.py_py38.snap index 10b925931c005..b8389e0889178 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A004_A004.py_py38.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A004_A004.py_py38.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs -snapshot_kind: text --- A004.py:1:16: A004 Import `sum` is shadowing a Python builtin | @@ -53,6 +52,6 @@ A004.py:5:30: A004 Import `dir` is shadowing a Python builtin 4 | from some import input, exec 5 | from directory import new as dir | ^^^ A004 -6 | +6 | 7 | # See: https://github.com/astral-sh/ruff/issues/13037 | diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A006_A006.py.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A006_A006.py.snap index 9ce6c7d1ddb0c..9c968e14f78d5 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A006_A006.py.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A006_A006.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs -snapshot_kind: text --- A006.py:1:8: A006 Lambda argument `print` is shadowing a Python builtin | @@ -62,6 +61,6 @@ A006.py:5:8: A006 Lambda argument `dir` is shadowing a Python builtin 4 | lambda id: id 5 | lambda dir: dir | ^^^ A006 -6 | +6 | 7 | # Ok for A006 - should trigger A002 instead | diff --git a/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81_syntax_error.py.snap b/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81_syntax_error.py.snap index 4133bee4d55a6..580392a4995cb 100644 --- a/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81_syntax_error.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_commas/mod.rs -snapshot_kind: text --- COM81_syntax_error.py:3:5: SyntaxError: Starred expression cannot be used here | @@ -14,7 +13,7 @@ COM81_syntax_error.py:3:5: SyntaxError: Starred expression cannot be used here COM81_syntax_error.py:6:9: SyntaxError: Type parameter list cannot be empty | 4 | ) -5 | +5 | 6 | def foo[(param1='test', param2='test',): | ^ 7 | pass @@ -23,7 +22,7 @@ COM81_syntax_error.py:6:9: SyntaxError: Type parameter list cannot be empty COM81_syntax_error.py:6:38: COM819 Trailing comma prohibited | 4 | ) -5 | +5 | 6 | def foo[(param1='test', param2='test',): | ^ COM819 7 | pass diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C400_C400.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C400_C400.py.snap index 440342ef81bb1..f5a75e8d17fab 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C400_C400.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C400_C400.py.snap @@ -72,7 +72,7 @@ C400.py:10:5: C400 [*] Unnecessary generator (rewrite using `list()`) 11 | | x for x in range(3) 12 | | ) | |_^ C400 -13 | +13 | 14 | # Strip parentheses from inner generators. | = help: Rewrite using `list()` @@ -135,7 +135,7 @@ C400.py:17:1: C400 [*] Unnecessary generator (rewrite as a list comprehension) 16 | list(((2 * x for x in range(3)))) 17 | list((((2 * x for x in range(3))))) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C400 -18 | +18 | 19 | # Not built-in list. | = help: Rewrite as a list comprehension diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C401_C401.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C401_C401.py.snap index fab816dd97371..57ce5fc2b5de9 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C401_C401.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C401_C401.py.snap @@ -50,7 +50,7 @@ C401.py:6:17: C401 [*] Unnecessary generator (rewrite as a set comprehension) 5 | ) 6 | small_nums = f"{set(a if a < 6 else 0 for a in range(3))}" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C401 -7 | +7 | 8 | def f(x): | = help: Rewrite as a set comprehension @@ -68,7 +68,7 @@ C401.py:6:17: C401 [*] Unnecessary generator (rewrite as a set comprehension) C401.py:11:16: C401 [*] Unnecessary generator (rewrite as a set comprehension) | 9 | return x -10 | +10 | 11 | print(f"Hello {set(f(a) for a in 'abc')} World") | ^^^^^^^^^^^^^^^^^^^^^^^^ C401 12 | print(f"Hello { set(f(a) for a in 'abc') } World") diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C402_C402.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C402_C402.py.snap index 58382cb5e424c..12c426627a6db 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C402_C402.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C402_C402.py.snap @@ -130,7 +130,7 @@ C402.py:10:16: C402 [*] Unnecessary generator (rewrite as a dict comprehension) 9 | print(f'Hello {dict((x, x) for x in "abc")} World') 10 | print(f'Hello {dict((x,x) for x in "abc")} World') | ^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 -11 | +11 | 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' | = help: Rewrite as a dict comprehension @@ -148,7 +148,7 @@ C402.py:10:16: C402 [*] Unnecessary generator (rewrite as a dict comprehension) C402.py:12:4: C402 [*] Unnecessary generator (rewrite as a dict comprehension) | 10 | print(f'Hello {dict((x,x) for x in "abc")} World') -11 | +11 | 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 13 | f'{ dict((x, x) for x in range(3)) | dict((x, x) for x in range(3)) }' @@ -168,7 +168,7 @@ C402.py:12:4: C402 [*] Unnecessary generator (rewrite as a dict comprehension) C402.py:12:37: C402 [*] Unnecessary generator (rewrite as a dict comprehension) | 10 | print(f'Hello {dict((x,x) for x in "abc")} World') -11 | +11 | 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 13 | f'{ dict((x, x) for x in range(3)) | dict((x, x) for x in range(3)) }' @@ -190,7 +190,7 @@ C402.py:13:5: C402 [*] Unnecessary generator (rewrite as a dict comprehension) 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' 13 | f'{ dict((x, x) for x in range(3)) | dict((x, x) for x in range(3)) }' | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 -14 | +14 | 15 | def f(x): | = help: Rewrite as a dict comprehension @@ -210,7 +210,7 @@ C402.py:13:38: C402 [*] Unnecessary generator (rewrite as a dict comprehension) 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' 13 | f'{ dict((x, x) for x in range(3)) | dict((x, x) for x in range(3)) }' | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 -14 | +14 | 15 | def f(x): | = help: Rewrite as a dict comprehension @@ -228,10 +228,10 @@ C402.py:13:38: C402 [*] Unnecessary generator (rewrite as a dict comprehension) C402.py:18:16: C402 [*] Unnecessary generator (rewrite as a dict comprehension) | 16 | return x -17 | +17 | 18 | print(f'Hello {dict((x,f(x)) for x in "abc")} World') | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 -19 | +19 | 20 | # Regression test for: https://github.com/astral-sh/ruff/issues/7086 | = help: Rewrite as a dict comprehension @@ -251,7 +251,7 @@ C402.py:21:1: C402 [*] Unnecessary generator (rewrite as a dict comprehension) 20 | # Regression test for: https://github.com/astral-sh/ruff/issues/7086 21 | dict((k,v)for k,v in d.iteritems() if k in only_args) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 -22 | +22 | 23 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458940 | = help: Rewrite as a dict comprehension diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C403_C403.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C403_C403.py.snap index 513dabb532005..6ea5a28385277 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C403_C403.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C403_C403.py.snap @@ -25,7 +25,7 @@ C403.py:2:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehen 3 | | [x for x in range(3)] 4 | | ) | |_^ C403 -5 | +5 | 6 | s = f"{set([x for x in 'ab'])}" | = help: Rewrite as a set comprehension @@ -45,7 +45,7 @@ C403.py:2:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehen C403.py:6:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) | 4 | ) -5 | +5 | 6 | s = f"{set([x for x in 'ab'])}" | ^^^^^^^^^^^^^^^^^^^^^^ C403 7 | s = f'{set([x for x in "ab"])}' @@ -67,7 +67,7 @@ C403.py:7:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehen 6 | s = f"{set([x for x in 'ab'])}" 7 | s = f'{set([x for x in "ab"])}' | ^^^^^^^^^^^^^^^^^^^^^^ C403 -8 | +8 | 9 | def f(x): | = help: Rewrite as a set comprehension @@ -85,10 +85,10 @@ C403.py:7:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehen C403.py:12:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) | 10 | return x -11 | +11 | 12 | s = f"{set([f(x) for x in 'ab'])}" | ^^^^^^^^^^^^^^^^^^^^^^^^^ C403 -13 | +13 | 14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" | = help: Rewrite as a set comprehension @@ -106,7 +106,7 @@ C403.py:12:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehe C403.py:14:9: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) | 12 | s = f"{set([f(x) for x in 'ab'])}" -13 | +13 | 14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" | ^^^^^^^^^^^^^^^^^^^^^^ C403 15 | s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" @@ -126,7 +126,7 @@ C403.py:14:9: C403 [*] Unnecessary list comprehension (rewrite as a set comprehe C403.py:14:34: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) | 12 | s = f"{set([f(x) for x in 'ab'])}" -13 | +13 | 14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" | ^^^^^^^^^^^^^^^^^^^^^^ C403 15 | s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" @@ -148,7 +148,7 @@ C403.py:15:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehe 14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" 15 | s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" | ^^^^^^^^^^^^^^^^^^^^^^ C403 -16 | +16 | 17 | s = set( # comment | = help: Rewrite as a set comprehension @@ -168,7 +168,7 @@ C403.py:15:33: C403 [*] Unnecessary list comprehension (rewrite as a set compreh 14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" 15 | s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" | ^^^^^^^^^^^^^^^^^^^^^^ C403 -16 | +16 | 17 | s = set( # comment | = help: Rewrite as a set comprehension @@ -186,13 +186,13 @@ C403.py:15:33: C403 [*] Unnecessary list comprehension (rewrite as a set compreh C403.py:17:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) | 15 | s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" -16 | +16 | 17 | s = set( # comment | _____^ 18 | | [x for x in range(3)] 19 | | ) | |_^ C403 -20 | +20 | 21 | s = set([ # comment | = help: Rewrite as a set comprehension @@ -214,7 +214,7 @@ C403.py:17:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehe C403.py:21:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) | 19 | ) -20 | +20 | 21 | s = set([ # comment | _____^ 22 | | x for x in range(3) diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C404_C404.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C404_C404.py.snap index cfea193b1c6cd..1267401cfd9e3 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C404_C404.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C404_C404.py.snap @@ -19,7 +19,7 @@ C404.py:1:1: C404 [*] Unnecessary list comprehension (rewrite as a dict comprehe C404.py:7:4: C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) | 5 | return x -6 | +6 | 7 | f'{dict([(s,s) for s in "ab"])}' | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 8 | f"{dict([(s,s) for s in 'ab'])}" @@ -83,7 +83,7 @@ C404.py:10:4: C404 [*] Unnecessary list comprehension (rewrite as a dict compreh 9 | f"{dict([(s, s) for s in 'ab'])}" 10 | f"{dict([(s,f(s)) for s in 'ab'])}" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 -11 | +11 | 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' | = help: Rewrite as a dict comprehension @@ -101,7 +101,7 @@ C404.py:10:4: C404 [*] Unnecessary list comprehension (rewrite as a dict compreh C404.py:12:4: C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) | 10 | f"{dict([(s,f(s)) for s in 'ab'])}" -11 | +11 | 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' @@ -121,7 +121,7 @@ C404.py:12:4: C404 [*] Unnecessary list comprehension (rewrite as a dict compreh C404.py:12:34: C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) | 10 | f"{dict([(s,f(s)) for s in 'ab'])}" -11 | +11 | 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' @@ -143,7 +143,7 @@ C404.py:13:5: C404 [*] Unnecessary list comprehension (rewrite as a dict compreh 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 -14 | +14 | 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 | = help: Rewrite as a dict comprehension @@ -163,7 +163,7 @@ C404.py:13:35: C404 [*] Unnecessary list comprehension (rewrite as a dict compre 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 -14 | +14 | 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 | = help: Rewrite as a dict comprehension diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C405_C405.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C405_C405.py.snap index 59d160bdc2483..b3c7e4b5bef18 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C405_C405.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C405_C405.py.snap @@ -247,7 +247,7 @@ C405.py:21:4: C405 [*] Unnecessary list literal (rewrite as a set literal) 20 | f"{set(['a', 'b'])}" 21 | f'{set(["a", "b"])}' | ^^^^^^^^^^^^^^^ C405 -22 | +22 | 23 | f"{set(['a', 'b']) - set(['a'])}" | = help: Rewrite as a set literal @@ -265,7 +265,7 @@ C405.py:21:4: C405 [*] Unnecessary list literal (rewrite as a set literal) C405.py:23:4: C405 [*] Unnecessary list literal (rewrite as a set literal) | 21 | f'{set(["a", "b"])}' -22 | +22 | 23 | f"{set(['a', 'b']) - set(['a'])}" | ^^^^^^^^^^^^^^^ C405 24 | f"{ set(['a', 'b']) - set(['a']) }" @@ -286,7 +286,7 @@ C405.py:23:4: C405 [*] Unnecessary list literal (rewrite as a set literal) C405.py:23:22: C405 [*] Unnecessary list literal (rewrite as a set literal) | 21 | f'{set(["a", "b"])}' -22 | +22 | 23 | f"{set(['a', 'b']) - set(['a'])}" | ^^^^^^^^^^ C405 24 | f"{ set(['a', 'b']) - set(['a']) }" diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py.snap index 8e2f993e3f55f..973aa65bc4076 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py.snap @@ -78,7 +78,7 @@ C408.py:4:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) C408.py:14:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) | 12 | a = list() -13 | +13 | 14 | f"{dict(x='y')}" | ^^^^^^^^^^^ C408 15 | f'{dict(x="y")}' @@ -142,7 +142,7 @@ C408.py:17:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 16 | f"{dict()}" 17 | f"a {dict()} b" | ^^^^^^ C408 -18 | +18 | 19 | f"{dict(x='y') | dict(y='z')}" | = help: Rewrite as a literal @@ -160,7 +160,7 @@ C408.py:17:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) C408.py:19:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) | 17 | f"a {dict()} b" -18 | +18 | 19 | f"{dict(x='y') | dict(y='z')}" | ^^^^^^^^^^^ C408 20 | f"{ dict(x='y') | dict(y='z') }" @@ -181,7 +181,7 @@ C408.py:19:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) C408.py:19:18: C408 [*] Unnecessary `dict()` call (rewrite as a literal) | 17 | f"a {dict()} b" -18 | +18 | 19 | f"{dict(x='y') | dict(y='z')}" | ^^^^^^^^^^^ C408 20 | f"{ dict(x='y') | dict(y='z') }" @@ -285,7 +285,7 @@ C408.py:22:7: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 21 | f"a {dict(x='y') | dict(y='z')} b" 22 | f"a { dict(x='y') | dict(y='z') } b" | ^^^^^^^^^^^ C408 -23 | +23 | 24 | dict( | = help: Rewrite as a literal @@ -306,7 +306,7 @@ C408.py:22:21: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 21 | f"a {dict(x='y') | dict(y='z')} b" 22 | f"a { dict(x='y') | dict(y='z') } b" | ^^^^^^^^^^^ C408 -23 | +23 | 24 | dict( | = help: Rewrite as a literal @@ -324,12 +324,12 @@ C408.py:22:21: C408 [*] Unnecessary `dict()` call (rewrite as a literal) C408.py:24:1: C408 [*] Unnecessary `dict()` call (rewrite as a literal) | 22 | f"a { dict(x='y') | dict(y='z') } b" -23 | +23 | 24 | / dict( 25 | | # comment 26 | | ) | |_^ C408 -27 | +27 | 28 | tuple( # comment | = help: Rewrite as a literal @@ -350,7 +350,7 @@ C408.py:24:1: C408 [*] Unnecessary `dict()` call (rewrite as a literal) C408.py:28:1: C408 [*] Unnecessary `tuple()` call (rewrite as a literal) | 26 | ) -27 | +27 | 28 | / tuple( # comment 29 | | ) | |_^ C408 diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py_allow_dict_calls_with_keyword_arguments.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py_allow_dict_calls_with_keyword_arguments.snap index 8e979ae7eceb0..17911683f1723 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py_allow_dict_calls_with_keyword_arguments.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py_allow_dict_calls_with_keyword_arguments.snap @@ -81,7 +81,7 @@ C408.py:17:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 16 | f"{dict()}" 17 | f"a {dict()} b" | ^^^^^^ C408 -18 | +18 | 19 | f"{dict(x='y') | dict(y='z')}" | = help: Rewrite as a literal @@ -99,12 +99,12 @@ C408.py:17:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) C408.py:24:1: C408 [*] Unnecessary `dict()` call (rewrite as a literal) | 22 | f"a { dict(x='y') | dict(y='z') } b" -23 | +23 | 24 | / dict( 25 | | # comment 26 | | ) | |_^ C408 -27 | +27 | 28 | tuple( # comment | = help: Rewrite as a literal @@ -125,7 +125,7 @@ C408.py:24:1: C408 [*] Unnecessary `dict()` call (rewrite as a literal) C408.py:28:1: C408 [*] Unnecessary `tuple()` call (rewrite as a literal) | 26 | ) -27 | +27 | 28 | / tuple( # comment 29 | | ) | |_^ C408 diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C409_C409.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C409_C409.py.snap index b432b42187d35..3b2fd728cc6c3 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C409_C409.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C409_C409.py.snap @@ -93,7 +93,7 @@ C409.py:8:6: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the 9 | | (1, 2) 10 | | ) | |_^ C409 -11 | +11 | 12 | tuple( # comment | = help: Remove the outer call to `tuple()` @@ -113,12 +113,12 @@ C409.py:8:6: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the C409.py:12:1: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) | 10 | ) -11 | +11 | 12 | / tuple( # comment 13 | | [1, 2] 14 | | ) | |_^ C409 -15 | +15 | 16 | tuple([ # comment | = help: Rewrite as a tuple literal @@ -138,12 +138,12 @@ C409.py:12:1: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as C409.py:16:1: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) | 14 | ) -15 | +15 | 16 | / tuple([ # comment 17 | | 1, 2 18 | | ]) | |__^ C409 -19 | +19 | 20 | tuple(( | = help: Rewrite as a tuple literal @@ -164,12 +164,12 @@ C409.py:16:1: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as C409.py:20:1: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the outer call to `tuple()`) | 18 | ]) -19 | +19 | 20 | / tuple(( 21 | | 1, 22 | | )) | |__^ C409 -23 | +23 | 24 | t6 = tuple([1]) | = help: Remove the outer call to `tuple()` @@ -190,7 +190,7 @@ C409.py:20:1: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the C409.py:24:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) | 22 | )) -23 | +23 | 24 | t6 = tuple([1]) | ^^^^^^^^^^ C409 25 | t7 = tuple((1,)) @@ -233,7 +233,7 @@ C409.py:26:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as 25 | t7 = tuple((1,)) 26 | t8 = tuple([1,]) | ^^^^^^^^^^^ C409 -27 | +27 | 28 | tuple([x for x in range(5)]) | = help: Rewrite as a tuple literal diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C410_C410.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C410_C410.py.snap index f33a4ed1ffd2f..9f9152383b8d1 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C410_C410.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C410_C410.py.snap @@ -79,7 +79,7 @@ C410.py:7:1: C410 [*] Unnecessary list literal passed to `list()` (remove the ou 8 | | [1, 2] 9 | | ) | |_^ C410 -10 | +10 | 11 | list([ # comment | = help: Remove outer `list()` call @@ -99,7 +99,7 @@ C410.py:7:1: C410 [*] Unnecessary list literal passed to `list()` (remove the ou C410.py:11:1: C410 [*] Unnecessary list literal passed to `list()` (remove the outer call to `list()`) | 9 | ) -10 | +10 | 11 | / list([ # comment 12 | | 1, 2 13 | | ]) diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C413_C413.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C413_C413.py.snap index 67c6d81d1ffec..d32a7b519760e 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C413_C413.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C413_C413.py.snap @@ -173,7 +173,7 @@ C413.py:11:1: C413 [*] Unnecessary `reversed()` call around `sorted()` 10 | reversed(sorted(x, reverse=x)) 11 | reversed(sorted(x, reverse=not x)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 -12 | +12 | 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 | = help: Remove unnecessary `reversed()` call @@ -213,7 +213,7 @@ C413.py:15:1: C413 [*] Unnecessary `reversed()` call around `sorted()` 14 | reversed(sorted(i for i in range(42))) 15 | reversed(sorted((i for i in range(42)), reverse=True)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 -16 | +16 | 17 | # Regression test for: https://github.com/astral-sh/ruff/issues/10335 | = help: Remove unnecessary `reversed()` call diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C414_C414.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C414_C414.py.snap index 253374a21dbc4..af3a238f648bb 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C414_C414.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C414_C414.py.snap @@ -451,7 +451,7 @@ C414.py:28:1: C414 [*] Unnecessary `reversed()` call within `sorted()` 27 | set(tuple()) 28 | sorted(reversed()) | ^^^^^^^^^^^^^^^^^^ C414 -29 | +29 | 30 | # Nested sorts with differing keyword arguments. Not flagged. | = help: Remove the inner `reversed()` call @@ -477,7 +477,7 @@ C414.py:37:27: C414 [*] Unnecessary `list()` call within `sorted()` 41 | | key=lambda xxxxx: xxxxx or "", 42 | | ) | |_^ C414 -43 | +43 | 44 | xxxxxxxxxxx_xxxxx_xxxxx = sorted( | = help: Remove the inner `list()` call @@ -495,7 +495,7 @@ C414.py:37:27: C414 [*] Unnecessary `list()` call within `sorted()` C414.py:44:27: C414 [*] Unnecessary `list()` call within `sorted()` | 42 | ) -43 | +43 | 44 | xxxxxxxxxxx_xxxxx_xxxxx = sorted( | ___________________________^ 45 | | list(x_xxxx_xxxxxxxxxxx_xxxxx.xxxx()), # xxxxxxxxxxx xxxxx xxxx xxx xx Nxxx diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C416_C416.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C416_C416.py.snap index 2170f4ae6e9d8..7266e76c5ecde 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C416_C416.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C416_C416.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs -snapshot_kind: text --- C416.py:6:1: C416 [*] Unnecessary list comprehension (rewrite using `list()`) | 4 | d = {"a": 1, "b": 2, "c": 3} -5 | +5 | 6 | [i for i in x] | ^^^^^^^^^^^^^^ C416 7 | {i for i in x} @@ -131,7 +130,7 @@ C416.py:25:70: C416 [*] Unnecessary list comprehension (rewrite using `list()`) 24 | # Regression test for: https://github.com/astral-sh/ruff/issues/7196 25 | any(len(symbol_table.get_by_type(symbol_type)) > 0 for symbol_type in[t for t in SymbolType]) | ^^^^^^^^^^^^^^^^^^^^^^^ C416 -26 | +26 | 27 | zz = [[1], [2], [3]] | = help: Rewrite using `list()` diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C417_C417.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C417_C417.py.snap index 69b8be4704427..bdd83974fd49d 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C417_C417.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C417_C417.py.snap @@ -236,7 +236,7 @@ C417.py:14:1: C417 [*] Unnecessary `map()` usage (rewrite using a list comprehen 13 | filter(func, map(lambda v: v, nums)) 14 | list(map(lambda x, y: x * y, nums)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -15 | +15 | 16 | # When inside f-string, then the fix should be surrounded by whitespace | = help: Replace `map()` with a list comprehension @@ -276,7 +276,7 @@ C417.py:18:8: C417 [*] Unnecessary `map()` usage (rewrite using a dict comprehen 17 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}" 18 | _ = f"{dict(map(lambda v: (v, v**2), nums))}" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -19 | +19 | 20 | # False negatives. | = help: Replace `map()` with a dict comprehension @@ -296,7 +296,7 @@ C417.py:36:1: C417 [*] Unnecessary `map()` usage (rewrite using a generator expr 35 | # Error: the `x` is overridden by the inner lambda. 36 | map(lambda x: lambda x: x, range(4)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -37 | +37 | 38 | # Ok because of the default parameters, and variadic arguments. | = help: Replace `map()` with a generator expression @@ -357,7 +357,7 @@ C417.py:49:1: C417 [*] Unnecessary `map()` usage (rewrite using a generator expr 48 | map(lambda x: x, (y if y else z)) 49 | map(lambda x: x, (x, y, z)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -50 | +50 | 51 | # See https://github.com/astral-sh/ruff/issues/14808 | = help: Replace `map()` with a generator expression diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C418_C418.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C418_C418.py.snap index 4480626dc6a4e..0a90ca25db454 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C418_C418.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C418_C418.py.snap @@ -63,7 +63,7 @@ C418.py:4:1: C418 [*] Unnecessary dict comprehension passed to `dict()` (remove 5 | | {'x': 1 for x in range(10)} 6 | | ) | |_^ C418 -7 | +7 | 8 | dict({}, a=1) | = help: Remove outer `dict()` call diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C420_C420.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C420_C420.py.snap index 8a77c9290e73a..2a45889f360df 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C420_C420.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C420_C420.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs -snapshot_kind: text --- C420.py:6:5: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead | @@ -61,7 +60,7 @@ C420.py:15:5: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fr C420.py:26:7: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead | 24 | return data -25 | +25 | 26 | f({c: "a" for c in "12345"}) # RUF025 | ^^^^^^^^^^^^^^^^^^^^^^^^^ C420 | diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__preview__C409_C409.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__preview__C409_C409.py.snap index 0b220bdcf385c..cdbe3af0c18af 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__preview__C409_C409.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__preview__C409_C409.py.snap @@ -93,7 +93,7 @@ C409.py:8:6: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the 9 | | (1, 2) 10 | | ) | |_^ C409 -11 | +11 | 12 | tuple( # comment | = help: Remove the outer call to `tuple()` @@ -113,12 +113,12 @@ C409.py:8:6: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the C409.py:12:1: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) | 10 | ) -11 | +11 | 12 | / tuple( # comment 13 | | [1, 2] 14 | | ) | |_^ C409 -15 | +15 | 16 | tuple([ # comment | = help: Rewrite as a tuple literal @@ -138,12 +138,12 @@ C409.py:12:1: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as C409.py:16:1: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) | 14 | ) -15 | +15 | 16 | / tuple([ # comment 17 | | 1, 2 18 | | ]) | |__^ C409 -19 | +19 | 20 | tuple(( | = help: Rewrite as a tuple literal @@ -164,12 +164,12 @@ C409.py:16:1: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as C409.py:20:1: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the outer call to `tuple()`) | 18 | ]) -19 | +19 | 20 | / tuple(( 21 | | 1, 22 | | )) | |__^ C409 -23 | +23 | 24 | t6 = tuple([1]) | = help: Remove the outer call to `tuple()` @@ -190,7 +190,7 @@ C409.py:20:1: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the C409.py:24:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) | 22 | )) -23 | +23 | 24 | t6 = tuple([1]) | ^^^^^^^^^^ C409 25 | t7 = tuple((1,)) @@ -233,7 +233,7 @@ C409.py:26:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as 25 | t7 = tuple((1,)) 26 | t8 = tuple([1,]) | ^^^^^^^^^^^ C409 -27 | +27 | 28 | tuple([x for x in range(5)]) | = help: Rewrite as a tuple literal @@ -251,7 +251,7 @@ C409.py:26:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as C409.py:28:1: C409 [*] Unnecessary list comprehension passed to `tuple()` (rewrite as a generator) | 26 | t8 = tuple([1,]) -27 | +27 | 28 | tuple([x for x in range(5)]) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C409 29 | tuple({x for x in range(10)}) diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ001_DTZ001.py.snap b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ001_DTZ001.py.snap index d82805ef664dc..05999334ca8e2 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ001_DTZ001.py.snap +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ001_DTZ001.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs -snapshot_kind: text --- DTZ001.py:4:1: DTZ001 `datetime.datetime()` called without a `tzinfo` argument | 3 | # no args 4 | datetime.datetime(2000, 1, 1, 0, 0, 0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ001 -5 | +5 | 6 | # none args | = help: Pass a `datetime.timezone` object to the `tzinfo` parameter @@ -17,7 +16,7 @@ DTZ001.py:7:1: DTZ001 `tzinfo=None` passed to `datetime.datetime()` 6 | # none args 7 | datetime.datetime(2000, 1, 1, 0, 0, 0, 0, None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ001 -8 | +8 | 9 | # not none arg | = help: Pass a `datetime.timezone` object to the `tzinfo` parameter @@ -27,7 +26,7 @@ DTZ001.py:13:1: DTZ001 `datetime.datetime()` called without a `tzinfo` argument 12 | # no kwargs 13 | datetime.datetime(2000, 1, 1, fold=1) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ001 -14 | +14 | 15 | # none kwargs | = help: Pass a `datetime.timezone` object to the `tzinfo` parameter @@ -37,7 +36,7 @@ DTZ001.py:16:1: DTZ001 `tzinfo=None` passed to `datetime.datetime()` 15 | # none kwargs 16 | datetime.datetime(2000, 1, 1, tzinfo=None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ001 -17 | +17 | 18 | from datetime import datetime | = help: Pass a `datetime.timezone` object to the `tzinfo` parameter @@ -47,7 +46,7 @@ DTZ001.py:21:1: DTZ001 `datetime.datetime()` called without a `tzinfo` argument 20 | # no args unqualified 21 | datetime(2000, 1, 1, 0, 0, 0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ001 -22 | +22 | 23 | # uses `astimezone` method | = help: Pass a `datetime.timezone` object to the `tzinfo` parameter diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ002_DTZ002.py.snap b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ002_DTZ002.py.snap index d00ec8092f68a..34a34d1d838d4 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ002_DTZ002.py.snap +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ002_DTZ002.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs -snapshot_kind: text --- DTZ002.py:4:1: DTZ002 `datetime.datetime.today()` used | 3 | # qualified 4 | datetime.datetime.today() | ^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ002 -5 | +5 | 6 | from datetime import datetime | = help: Use `datetime.datetime.now(tz=...)` instead @@ -17,7 +16,7 @@ DTZ002.py:9:1: DTZ002 `datetime.datetime.today()` used 8 | # unqualified 9 | datetime.today() | ^^^^^^^^^^^^^^^^ DTZ002 -10 | +10 | 11 | # uses `astimezone` method | = help: Use `datetime.datetime.now(tz=...)` instead diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ003_DTZ003.py.snap b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ003_DTZ003.py.snap index f860d0aba8622..b436bff261cae 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ003_DTZ003.py.snap +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ003_DTZ003.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs -snapshot_kind: text --- DTZ003.py:4:1: DTZ003 `datetime.datetime.utcnow()` used | 3 | # qualified 4 | datetime.datetime.utcnow() | ^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ003 -5 | +5 | 6 | from datetime import datetime | = help: Use `datetime.datetime.now(tz=...)` instead @@ -17,7 +16,7 @@ DTZ003.py:9:1: DTZ003 `datetime.datetime.utcnow()` used 8 | # unqualified 9 | datetime.utcnow() | ^^^^^^^^^^^^^^^^^ DTZ003 -10 | +10 | 11 | # uses `astimezone` method | = help: Use `datetime.datetime.now(tz=...)` instead diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ004_DTZ004.py.snap b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ004_DTZ004.py.snap index c646046dcdecb..41c2b782a9ecb 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ004_DTZ004.py.snap +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ004_DTZ004.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs -snapshot_kind: text --- DTZ004.py:4:1: DTZ004 `datetime.datetime.utcfromtimestamp()` used | 3 | # qualified 4 | datetime.datetime.utcfromtimestamp(1234) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ004 -5 | +5 | 6 | from datetime import datetime | = help: Use `datetime.datetime.fromtimestamp(ts, tz=...)` instead @@ -17,7 +16,7 @@ DTZ004.py:9:1: DTZ004 `datetime.datetime.utcfromtimestamp()` used 8 | # unqualified 9 | datetime.utcfromtimestamp(1234) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ004 -10 | +10 | 11 | # uses `astimezone` method | = help: Use `datetime.datetime.fromtimestamp(ts, tz=...)` instead diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ005_DTZ005.py.snap b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ005_DTZ005.py.snap index 114c19ca7b760..b3a3ce328c173 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ005_DTZ005.py.snap +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ005_DTZ005.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs -snapshot_kind: text --- DTZ005.py:4:1: DTZ005 `datetime.datetime.now()` called without a `tz` argument | 3 | # no args 4 | datetime.datetime.now() | ^^^^^^^^^^^^^^^^^^^^^^^ DTZ005 -5 | +5 | 6 | # wrong keywords | = help: Pass a `datetime.timezone` object to the `tz` parameter @@ -17,7 +16,7 @@ DTZ005.py:7:1: DTZ005 `datetime.datetime.now()` called without a `tz` argument 6 | # wrong keywords 7 | datetime.datetime.now(bad=datetime.timezone.utc) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ005 -8 | +8 | 9 | # none args | = help: Pass a `datetime.timezone` object to the `tz` parameter @@ -27,7 +26,7 @@ DTZ005.py:10:1: DTZ005 `tz=None` passed to `datetime.datetime.now()` 9 | # none args 10 | datetime.datetime.now(None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ005 -11 | +11 | 12 | # none keywords | = help: Pass a `datetime.timezone` object to the `tz` parameter @@ -37,7 +36,7 @@ DTZ005.py:13:1: DTZ005 `tz=None` passed to `datetime.datetime.now()` 12 | # none keywords 13 | datetime.datetime.now(tz=None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ005 -14 | +14 | 15 | from datetime import datetime | = help: Pass a `datetime.timezone` object to the `tz` parameter @@ -47,7 +46,7 @@ DTZ005.py:18:1: DTZ005 `datetime.datetime.now()` called without a `tz` argument 17 | # no args unqualified 18 | datetime.now() | ^^^^^^^^^^^^^^ DTZ005 -19 | +19 | 20 | # uses `astimezone` method | = help: Pass a `datetime.timezone` object to the `tz` parameter diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ006_DTZ006.py.snap b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ006_DTZ006.py.snap index d0c0982f8ae23..7ce79909c4d36 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ006_DTZ006.py.snap +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ006_DTZ006.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs -snapshot_kind: text --- DTZ006.py:4:1: DTZ006 `datetime.datetime.fromtimestamp()` called without a `tz` argument | 3 | # no args 4 | datetime.datetime.fromtimestamp(1234) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ006 -5 | +5 | 6 | # wrong keywords | = help: Pass a `datetime.timezone` object to the `tz` parameter @@ -17,7 +16,7 @@ DTZ006.py:7:1: DTZ006 `datetime.datetime.fromtimestamp()` called without a `tz` 6 | # wrong keywords 7 | datetime.datetime.fromtimestamp(1234, bad=datetime.timezone.utc) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ006 -8 | +8 | 9 | # none args | = help: Pass a `datetime.timezone` object to the `tz` parameter @@ -27,7 +26,7 @@ DTZ006.py:10:1: DTZ006 `tz=None` passed to `datetime.datetime.fromtimestamp()` 9 | # none args 10 | datetime.datetime.fromtimestamp(1234, None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ006 -11 | +11 | 12 | # none keywords | = help: Pass a `datetime.timezone` object to the `tz` parameter @@ -37,7 +36,7 @@ DTZ006.py:13:1: DTZ006 `tz=None` passed to `datetime.datetime.fromtimestamp()` 12 | # none keywords 13 | datetime.datetime.fromtimestamp(1234, tz=None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ006 -14 | +14 | 15 | from datetime import datetime | = help: Pass a `datetime.timezone` object to the `tz` parameter @@ -47,7 +46,7 @@ DTZ006.py:18:1: DTZ006 `datetime.datetime.fromtimestamp()` called without a `tz` 17 | # no args unqualified 18 | datetime.fromtimestamp(1234) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ006 -19 | +19 | 20 | # uses `astimezone` method | = help: Pass a `datetime.timezone` object to the `tz` parameter diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ007_DTZ007.py.snap b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ007_DTZ007.py.snap index 797114eba7bff..06b7452962057 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ007_DTZ007.py.snap +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ007_DTZ007.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs -snapshot_kind: text --- DTZ007.py:4:1: DTZ007 Naive datetime constructed using `datetime.datetime.strptime()` without %z | 3 | # bad format 4 | datetime.datetime.strptime("something", "%H:%M:%S%Z") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007 -5 | +5 | 6 | # no replace or astimezone | = help: Call `.replace(tzinfo=)` or `.astimezone()` to convert to an aware datetime @@ -17,7 +16,7 @@ DTZ007.py:7:1: DTZ007 Naive datetime constructed using `datetime.datetime.strpti 6 | # no replace or astimezone 7 | datetime.datetime.strptime("something", "something") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007 -8 | +8 | 9 | # wrong replace | = help: Call `.replace(tzinfo=)` or `.astimezone()` to convert to an aware datetime @@ -27,7 +26,7 @@ DTZ007.py:10:1: DTZ007 Naive datetime constructed using `datetime.datetime.strpt 9 | # wrong replace 10 | datetime.datetime.strptime("something", "something").replace(hour=1) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007 -11 | +11 | 12 | # none replace | = help: Call `.replace(tzinfo=)` or `.astimezone()` to convert to an aware datetime @@ -37,7 +36,7 @@ DTZ007.py:13:1: DTZ007 `datetime.datetime.strptime(...).replace(tz=None)` used 12 | # none replace 13 | datetime.datetime.strptime("something", "something").replace(tzinfo=None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007 -14 | +14 | 15 | # OK | = help: Pass a `datetime.timezone` object to the `tzinfo` parameter @@ -47,7 +46,7 @@ DTZ007.py:35:1: DTZ007 Naive datetime constructed using `datetime.datetime.strpt 34 | # no replace orastimezone unqualified 35 | datetime.strptime("something", "something") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007 -36 | +36 | 37 | # F-strings | = help: Call `.replace(tzinfo=)` or `.astimezone()` to convert to an aware datetime diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ011_DTZ011.py.snap b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ011_DTZ011.py.snap index 86a4e68ad926e..b15b8f9266a4c 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ011_DTZ011.py.snap +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ011_DTZ011.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs -snapshot_kind: text --- DTZ011.py:4:1: DTZ011 `datetime.date.today()` used | 3 | # qualified 4 | datetime.date.today() | ^^^^^^^^^^^^^^^^^^^^^ DTZ011 -5 | +5 | 6 | from datetime import date | = help: Use `datetime.datetime.now(tz=...).date()` instead diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ012_DTZ012.py.snap b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ012_DTZ012.py.snap index adb19fe82330e..2c8ab9d3214fe 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ012_DTZ012.py.snap +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ012_DTZ012.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs -snapshot_kind: text --- DTZ012.py:4:1: DTZ012 `datetime.date.fromtimestamp()` used | 3 | # qualified 4 | datetime.date.fromtimestamp(1234) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ012 -5 | +5 | 6 | from datetime import date | = help: Use `datetime.datetime.fromtimestamp(ts, tz=...).date()` instead diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ901_DTZ901.py.snap b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ901_DTZ901.py.snap index 29636c3fca91d..87a4d1a557191 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ901_DTZ901.py.snap +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ901_DTZ901.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs -snapshot_kind: text --- DTZ901.py:5:1: DTZ901 Use of `datetime.datetime.max` without timezone information | @@ -17,7 +16,7 @@ DTZ901.py:6:1: DTZ901 Use of `datetime.datetime.min` without timezone informatio 5 | datetime.datetime.max 6 | datetime.datetime.min | ^^^^^^^^^^^^^^^^^^^^^ DTZ901 -7 | +7 | 8 | datetime.datetime.max.replace(year=...) | = help: Replace with `datetime.datetime.min.replace(tzinfo=...)` @@ -25,7 +24,7 @@ DTZ901.py:6:1: DTZ901 Use of `datetime.datetime.min` without timezone informatio DTZ901.py:8:1: DTZ901 Use of `datetime.datetime.max` without timezone information | 6 | datetime.datetime.min -7 | +7 | 8 | datetime.datetime.max.replace(year=...) | ^^^^^^^^^^^^^^^^^^^^^ DTZ901 9 | datetime.datetime.min.replace(hour=...) @@ -55,7 +54,7 @@ DTZ901.py:28:1: DTZ901 Use of `datetime.datetime.min` without timezone informati 27 | datetime.max 28 | datetime.min | ^^^^^^^^^^^^ DTZ901 -29 | +29 | 30 | datetime.max.replace(year=...) | = help: Replace with `datetime.datetime.min.replace(tzinfo=...)` @@ -63,7 +62,7 @@ DTZ901.py:28:1: DTZ901 Use of `datetime.datetime.min` without timezone informati DTZ901.py:30:1: DTZ901 Use of `datetime.datetime.max` without timezone information | 28 | datetime.min -29 | +29 | 30 | datetime.max.replace(year=...) | ^^^^^^^^^^^^ DTZ901 31 | datetime.min.replace(hour=...) diff --git a/crates/ruff_linter/src/rules/flake8_debugger/snapshots/ruff_linter__rules__flake8_debugger__tests__T100_T100.py.snap b/crates/ruff_linter/src/rules/flake8_debugger/snapshots/ruff_linter__rules__flake8_debugger__tests__T100_T100.py.snap index 70989d4cf9844..3b8f68333cd85 100644 --- a/crates/ruff_linter/src/rules/flake8_debugger/snapshots/ruff_linter__rules__flake8_debugger__tests__T100_T100.py.snap +++ b/crates/ruff_linter/src/rules/flake8_debugger/snapshots/ruff_linter__rules__flake8_debugger__tests__T100_T100.py.snap @@ -1,19 +1,18 @@ --- source: crates/ruff_linter/src/rules/flake8_debugger/mod.rs -snapshot_kind: text --- T100.py:1:1: T100 Trace found: `breakpoint` used | 1 | breakpoint() | ^^^^^^^^^^^^ T100 -2 | +2 | 3 | import pdb | T100.py:3:1: T100 Import for `pdb` found | 1 | breakpoint() -2 | +2 | 3 | import pdb | ^^^^^^^^^^ T100 4 | import builtins @@ -105,14 +104,14 @@ T100.py:15:1: T100 Import for `ptvsd` found 14 | from ptvsd import wait_for_attach 15 | import ptvsd | ^^^^^^^^^^^^ T100 -16 | +16 | 17 | breakpoint() | T100.py:17:1: T100 Trace found: `builtins.breakpoint` used | 15 | import ptvsd -16 | +16 | 17 | breakpoint() | ^^^^^^^^^^^^ T100 18 | st() diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE001_1.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE001_1.py.snap index ba870fb9657b3..3ebc57f8bb34c 100644 --- a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE001_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE001_1.py.snap @@ -5,7 +5,6 @@ EXE001_1.py:1:1: EXE001 Shebang is present but file is not executable | 1 | #!/usr/bin/python | ^^^^^^^^^^^^^^^^^ EXE001 -2 | +2 | 3 | if __name__ == '__main__': | - diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_4.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_4.py.snap index feff95aa86af5..5cd13ffc0428b 100644 --- a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_4.py.snap +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_4.py.snap @@ -3,7 +3,7 @@ source: crates/ruff_linter/src/rules/flake8_executable/mod.rs --- EXE004_4.py:1:1: EXE004 [*] Avoid whitespace before shebang | -1 | / +1 | / 2 | | #!/usr/bin/env python | |____^ EXE004 | @@ -13,5 +13,3 @@ EXE004_4.py:1:1: EXE004 [*] Avoid whitespace before shebang 1 |- 2 |- #!/usr/bin/env python 1 |+#!/usr/bin/env python - - diff --git a/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-fixme_T00.py.snap b/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-fixme_T00.py.snap index 8c9650b550de6..a127236782c6c 100644 --- a/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-fixme_T00.py.snap +++ b/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-fixme_T00.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_fixme/mod.rs -snapshot_kind: text --- T00.py:7:3: FIX001 Line contains FIXME, consider resolving the issue | @@ -17,6 +16,6 @@ T00.py:8:3: FIX001 Line contains FIXME, consider resolving the issue 7 | # FIXME: fixme 8 | # fixme: fixme | ^^^^^ FIX001 - 9 | + 9 | 10 | # test # TODO: todo | diff --git a/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-todo_T00.py.snap b/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-todo_T00.py.snap index 3d064fbd7c0a2..b4477356751ca 100644 --- a/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-todo_T00.py.snap +++ b/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-todo_T00.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_fixme/mod.rs -snapshot_kind: text --- T00.py:1:3: FIX002 Line contains TODO, consider resolving the issue | @@ -22,7 +21,7 @@ T00.py:2:3: FIX002 Line contains TODO, consider resolving the issue T00.py:10:10: FIX002 Line contains TODO, consider resolving the issue | 8 | # fixme: fixme - 9 | + 9 | 10 | # test # TODO: todo | ^^^^ FIX002 | diff --git a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC.py.snap b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC.py.snap index aab4a381d1dc1..73d16d6ebd2b2 100644 --- a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC.py.snap +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs -snapshot_kind: text --- ISC.py:1:5: ISC001 [*] Implicitly concatenated string literals on one line | 1 | _ = "a" "b" "c" | ^^^^^^^ ISC001 -2 | +2 | 3 | _ = "abc" + "def" | = help: Combine string literals @@ -22,7 +21,7 @@ ISC.py:1:9: ISC001 [*] Implicitly concatenated string literals on one line | 1 | _ = "a" "b" "c" | ^^^^^^^ ISC001 -2 | +2 | 3 | _ = "abc" + "def" | = help: Combine string literals @@ -37,10 +36,10 @@ ISC.py:1:9: ISC001 [*] Implicitly concatenated string literals on one line ISC.py:38:5: ISC001 [*] Implicitly concatenated string literals on one line | 36 | ) -37 | +37 | 38 | _ = """a""" """b""" | ^^^^^^^^^^^^^^^ ISC001 -39 | +39 | 40 | _ = """a | = help: Combine string literals @@ -58,13 +57,13 @@ ISC.py:38:5: ISC001 [*] Implicitly concatenated string literals on one line ISC.py:40:5: ISC001 [*] Implicitly concatenated string literals on one line | 38 | _ = """a""" """b""" -39 | +39 | 40 | _ = """a | _____^ 41 | | b""" """c 42 | | d""" | |____^ ISC001 -43 | +43 | 44 | _ = f"""a""" f"""b""" | = help: Combine string literals @@ -82,10 +81,10 @@ ISC.py:40:5: ISC001 [*] Implicitly concatenated string literals on one line ISC.py:44:5: ISC001 [*] Implicitly concatenated string literals on one line | 42 | d""" -43 | +43 | 44 | _ = f"""a""" f"""b""" | ^^^^^^^^^^^^^^^^^ ISC001 -45 | +45 | 46 | _ = f"a" "b" | = help: Combine string literals @@ -103,10 +102,10 @@ ISC.py:44:5: ISC001 [*] Implicitly concatenated string literals on one line ISC.py:46:5: ISC001 Implicitly concatenated string literals on one line | 44 | _ = f"""a""" f"""b""" -45 | +45 | 46 | _ = f"a" "b" | ^^^^^^^^ ISC001 -47 | +47 | 48 | _ = """a""" "b" | = help: Combine string literals @@ -114,10 +113,10 @@ ISC.py:46:5: ISC001 Implicitly concatenated string literals on one line ISC.py:48:5: ISC001 Implicitly concatenated string literals on one line | 46 | _ = f"a" "b" -47 | +47 | 48 | _ = """a""" "b" | ^^^^^^^^^^^ ISC001 -49 | +49 | 50 | _ = 'a' "b" | = help: Combine string literals @@ -125,10 +124,10 @@ ISC.py:48:5: ISC001 Implicitly concatenated string literals on one line ISC.py:50:5: ISC001 Implicitly concatenated string literals on one line | 48 | _ = """a""" "b" -49 | +49 | 50 | _ = 'a' "b" | ^^^^^^^ ISC001 -51 | +51 | 52 | _ = rf"a" rf"b" | = help: Combine string literals @@ -136,10 +135,10 @@ ISC.py:50:5: ISC001 Implicitly concatenated string literals on one line ISC.py:52:5: ISC001 [*] Implicitly concatenated string literals on one line | 50 | _ = 'a' "b" -51 | +51 | 52 | _ = rf"a" rf"b" | ^^^^^^^^^^^ ISC001 -53 | +53 | 54 | # Single-line explicit concatenation should be ignored. | = help: Combine string literals diff --git a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC002_ISC.py.snap b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC002_ISC.py.snap index 02d08ef45c7c2..42e5ca2717d6c 100644 --- a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC002_ISC.py.snap +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC002_ISC.py.snap @@ -1,16 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs -snapshot_kind: text --- ISC.py:5:5: ISC002 Implicitly concatenated string literals over multiple lines | 3 | _ = "abc" + "def" -4 | +4 | 5 | _ = "abc" \ | _____^ 6 | | "def" | |_________^ ISC002 -7 | +7 | 8 | _ = ( | @@ -22,6 +21,6 @@ ISC.py:74:10: ISC002 Implicitly concatenated string literals over multiple lines | __________^ 75 | | f"def"} g" | |__________^ ISC002 -76 | +76 | 77 | # Explicitly concatenated nested f-strings | diff --git a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC001_ISC.py.snap b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC001_ISC.py.snap index aab4a381d1dc1..73d16d6ebd2b2 100644 --- a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC001_ISC.py.snap +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC001_ISC.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs -snapshot_kind: text --- ISC.py:1:5: ISC001 [*] Implicitly concatenated string literals on one line | 1 | _ = "a" "b" "c" | ^^^^^^^ ISC001 -2 | +2 | 3 | _ = "abc" + "def" | = help: Combine string literals @@ -22,7 +21,7 @@ ISC.py:1:9: ISC001 [*] Implicitly concatenated string literals on one line | 1 | _ = "a" "b" "c" | ^^^^^^^ ISC001 -2 | +2 | 3 | _ = "abc" + "def" | = help: Combine string literals @@ -37,10 +36,10 @@ ISC.py:1:9: ISC001 [*] Implicitly concatenated string literals on one line ISC.py:38:5: ISC001 [*] Implicitly concatenated string literals on one line | 36 | ) -37 | +37 | 38 | _ = """a""" """b""" | ^^^^^^^^^^^^^^^ ISC001 -39 | +39 | 40 | _ = """a | = help: Combine string literals @@ -58,13 +57,13 @@ ISC.py:38:5: ISC001 [*] Implicitly concatenated string literals on one line ISC.py:40:5: ISC001 [*] Implicitly concatenated string literals on one line | 38 | _ = """a""" """b""" -39 | +39 | 40 | _ = """a | _____^ 41 | | b""" """c 42 | | d""" | |____^ ISC001 -43 | +43 | 44 | _ = f"""a""" f"""b""" | = help: Combine string literals @@ -82,10 +81,10 @@ ISC.py:40:5: ISC001 [*] Implicitly concatenated string literals on one line ISC.py:44:5: ISC001 [*] Implicitly concatenated string literals on one line | 42 | d""" -43 | +43 | 44 | _ = f"""a""" f"""b""" | ^^^^^^^^^^^^^^^^^ ISC001 -45 | +45 | 46 | _ = f"a" "b" | = help: Combine string literals @@ -103,10 +102,10 @@ ISC.py:44:5: ISC001 [*] Implicitly concatenated string literals on one line ISC.py:46:5: ISC001 Implicitly concatenated string literals on one line | 44 | _ = f"""a""" f"""b""" -45 | +45 | 46 | _ = f"a" "b" | ^^^^^^^^ ISC001 -47 | +47 | 48 | _ = """a""" "b" | = help: Combine string literals @@ -114,10 +113,10 @@ ISC.py:46:5: ISC001 Implicitly concatenated string literals on one line ISC.py:48:5: ISC001 Implicitly concatenated string literals on one line | 46 | _ = f"a" "b" -47 | +47 | 48 | _ = """a""" "b" | ^^^^^^^^^^^ ISC001 -49 | +49 | 50 | _ = 'a' "b" | = help: Combine string literals @@ -125,10 +124,10 @@ ISC.py:48:5: ISC001 Implicitly concatenated string literals on one line ISC.py:50:5: ISC001 Implicitly concatenated string literals on one line | 48 | _ = """a""" "b" -49 | +49 | 50 | _ = 'a' "b" | ^^^^^^^ ISC001 -51 | +51 | 52 | _ = rf"a" rf"b" | = help: Combine string literals @@ -136,10 +135,10 @@ ISC.py:50:5: ISC001 Implicitly concatenated string literals on one line ISC.py:52:5: ISC001 [*] Implicitly concatenated string literals on one line | 50 | _ = 'a' "b" -51 | +51 | 52 | _ = rf"a" rf"b" | ^^^^^^^^^^^ ISC001 -53 | +53 | 54 | # Single-line explicit concatenation should be ignored. | = help: Combine string literals diff --git a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom.snap b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom.snap index c53b5a252f317..dc6fb5571355b 100644 --- a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom.snap +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs -snapshot_kind: text --- custom.py:3:8: ICN001 `altair` should be imported as `alt` | 1 | import math # not checked -2 | +2 | 3 | import altair # unconventional | ^^^^^^ ICN001 4 | import dask.array # unconventional @@ -149,7 +148,7 @@ custom.py:16:8: ICN001 `pyarrow` should be imported as `pa` 15 | import polars # unconventional 16 | import pyarrow # unconventional | ^^^^^^^ ICN001 -17 | +17 | 18 | import altair as altr # unconventional | = help: Alias `pyarrow` to `pa` @@ -157,7 +156,7 @@ custom.py:16:8: ICN001 `pyarrow` should be imported as `pa` custom.py:18:18: ICN001 `altair` should be imported as `alt` | 16 | import pyarrow # unconventional -17 | +17 | 18 | import altair as altr # unconventional | ^^^^ ICN001 19 | import matplotlib.pyplot as plot # unconventional @@ -301,7 +300,7 @@ custom.py:31:19: ICN001 `pyarrow` should be imported as `pa` 30 | import polars as ps # unconventional 31 | import pyarrow as arr # unconventional | ^^^ ICN001 -32 | +32 | 33 | import altair as alt # conventional | = help: Alias `pyarrow` to `pa` diff --git a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom_banned.snap b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom_banned.snap index 2b2185e4957df..7559c7044092f 100644 --- a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom_banned.snap +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom_banned.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs -snapshot_kind: text --- custom_banned.py:1:1: ICN002 `typing` should not be imported as `t` | @@ -14,14 +13,14 @@ custom_banned.py:2:1: ICN002 `typing` should not be imported as `ty` 1 | import typing as t # banned 2 | import typing as ty # banned | ^^^^^^^^^^^^^^^^^^^ ICN002 -3 | +3 | 4 | import numpy as nmp # banned | custom_banned.py:4:1: ICN002 `numpy` should not be imported as `nmp` | 2 | import typing as ty # banned -3 | +3 | 4 | import numpy as nmp # banned | ^^^^^^^^^^^^^^^^^^^ ICN002 5 | import numpy as npy # banned @@ -72,6 +71,6 @@ custom_banned.py:9:1: ICN002 `torch.nn.functional` should not be imported as `F` 8 | from tensorflow.keras import backend as K # banned 9 | from torch.nn import functional as F # banned | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN002 -10 | +10 | 11 | from typing import Any # ok | diff --git a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom_banned_from.snap b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom_banned_from.snap index 0189ad3972ced..f40db3b4c088f 100644 --- a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom_banned_from.snap +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom_banned_from.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs -snapshot_kind: text --- custom_banned_from.py:1:1: ICN003 Members of `logging.config` should not be imported explicitly | @@ -24,14 +23,14 @@ custom_banned_from.py:3:1: ICN003 Members of `typing` should not be imported exp 2 | from typing import Any, Dict # banned 3 | from typing import * # banned | ^^^^^^^^^^^^^^^^^^^^ ICN003 -4 | +4 | 5 | from pandas import DataFrame # banned | custom_banned_from.py:5:1: ICN003 Members of `pandas` should not be imported explicitly | 3 | from typing import * # banned -4 | +4 | 5 | from pandas import DataFrame # banned | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN003 6 | from pandas import * # banned @@ -42,6 +41,6 @@ custom_banned_from.py:6:1: ICN003 Members of `pandas` should not be imported exp 5 | from pandas import DataFrame # banned 6 | from pandas import * # banned | ^^^^^^^^^^^^^^^^^^^^ ICN003 -7 | +7 | 8 | import logging.config # ok | diff --git a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__from_imports.snap b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__from_imports.snap index d642e4f2811c5..3cafb07489aba 100644 --- a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__from_imports.snap +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__from_imports.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs -snapshot_kind: text --- from_imports.py:3:8: ICN001 `xml.dom.minidom` should be imported as `md` | @@ -84,7 +83,7 @@ from_imports.py:10:57: ICN001 `xml.dom.minidom.parseString` should be imported a 9 | from xml.dom.minidom import parse, parseString 10 | from xml.dom.minidom import parse as ps, parseString as wrong | ^^^^^ ICN001 -11 | +11 | 12 | # No ICN001 violations | = help: Alias `xml.dom.minidom.parseString` to `pstr` diff --git a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__override_defaults.snap b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__override_defaults.snap index 16b6eece77374..16911e7f221fa 100644 --- a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__override_defaults.snap +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__override_defaults.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs -snapshot_kind: text --- override_default.py:3:8: ICN001 `altair` should be imported as `alt` | 1 | import math # not checked -2 | +2 | 3 | import altair # unconventional | ^^^^^^ ICN001 4 | import matplotlib.pyplot # unconventional @@ -50,7 +49,7 @@ override_default.py:7:8: ICN001 `seaborn` should be imported as `sns` 6 | import pandas # unconventional 7 | import seaborn # unconventional | ^^^^^^^ ICN001 -8 | +8 | 9 | import altair as altr # unconventional | = help: Alias `seaborn` to `sns` @@ -58,7 +57,7 @@ override_default.py:7:8: ICN001 `seaborn` should be imported as `sns` override_default.py:9:18: ICN001 `altair` should be imported as `alt` | 7 | import seaborn # unconventional - 8 | + 8 | 9 | import altair as altr # unconventional | ^^^^ ICN001 10 | import matplotlib.pyplot as plot # unconventional @@ -103,7 +102,7 @@ override_default.py:13:19: ICN001 `seaborn` should be imported as `sns` 12 | import pandas as pdas # unconventional 13 | import seaborn as sbrn # unconventional | ^^^^ ICN001 -14 | +14 | 15 | import altair as alt # conventional | = help: Alias `seaborn` to `sns` diff --git a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__remove_defaults.snap b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__remove_defaults.snap index 4db12756a0ad7..daf24699fc9e7 100644 --- a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__remove_defaults.snap +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__remove_defaults.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs -snapshot_kind: text --- remove_default.py:3:8: ICN001 `altair` should be imported as `alt` | 1 | import math # not checked -2 | +2 | 3 | import altair # unconventional | ^^^^^^ ICN001 4 | import matplotlib.pyplot # unconventional @@ -39,7 +38,7 @@ remove_default.py:7:8: ICN001 `seaborn` should be imported as `sns` 6 | import pandas # unconventional 7 | import seaborn # unconventional | ^^^^^^^ ICN001 -8 | +8 | 9 | import altair as altr # unconventional | = help: Alias `seaborn` to `sns` @@ -47,7 +46,7 @@ remove_default.py:7:8: ICN001 `seaborn` should be imported as `sns` remove_default.py:9:18: ICN001 `altair` should be imported as `alt` | 7 | import seaborn # unconventional - 8 | + 8 | 9 | import altair as altr # unconventional | ^^^^ ICN001 10 | import matplotlib.pyplot as plot # unconventional @@ -81,7 +80,7 @@ remove_default.py:13:19: ICN001 `seaborn` should be imported as `sns` 12 | import pandas as pdas # unconventional 13 | import seaborn as sbrn # unconventional | ^^^^ ICN001 -14 | +14 | 15 | import altair as alt # conventional | = help: Alias `seaborn` to `sns` diff --git a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG001_LOG001.py.snap b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG001_LOG001.py.snap index e4eea11910fb4..c46ebbc1e5463 100644 --- a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG001_LOG001.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG001_LOG001.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_logging/mod.rs -snapshot_kind: text --- LOG001.py:3:1: LOG001 [*] Use `logging.getLogger()` to instantiate loggers | 1 | import logging -2 | +2 | 3 | logging.Logger(__name__) | ^^^^^^^^^^^^^^ LOG001 4 | logging.Logger() diff --git a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG002_LOG002.py.snap b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG002_LOG002.py.snap index 58a4e4af4b254..25a78dfdb0561 100644 --- a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG002_LOG002.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG002_LOG002.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_logging/mod.rs -snapshot_kind: text --- LOG002.py:11:11: LOG002 [*] Use `__name__` with `logging.getLogger()` | @@ -27,7 +26,7 @@ LOG002.py:12:24: LOG002 [*] Use `__name__` with `logging.getLogger()` 11 | getLogger(__file__) 12 | logging.getLogger(name=__file__) | ^^^^^^^^ LOG002 -13 | +13 | 14 | logging.getLogger(__cached__) | = help: Replace with `__name__` @@ -45,7 +44,7 @@ LOG002.py:12:24: LOG002 [*] Use `__name__` with `logging.getLogger()` LOG002.py:14:19: LOG002 [*] Use `__name__` with `logging.getLogger()` | 12 | logging.getLogger(name=__file__) -13 | +13 | 14 | logging.getLogger(__cached__) | ^^^^^^^^^^ LOG002 15 | getLogger(name=__cached__) diff --git a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG007_LOG007.py.snap b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG007_LOG007.py.snap index c700825d18177..b98d744c20a17 100644 --- a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG007_LOG007.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG007_LOG007.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_logging/mod.rs -snapshot_kind: text --- LOG007.py:6:1: LOG007 Use of `logging.exception` with falsy `exc_info` | @@ -44,7 +43,7 @@ LOG007.py:10:1: LOG007 Use of `logging.exception` with falsy `exc_info` LOG007.py:17:1: LOG007 Use of `logging.exception` with falsy `exc_info` | 15 | from logging import exception -16 | +16 | 17 | exception("foo", exc_info=False) # LOG007 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LOG007 18 | exception("foo", exc_info=True) # OK diff --git a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG009_LOG009.py.snap b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG009_LOG009.py.snap index 1da6b8e358e29..7d18aeb14ece5 100644 --- a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG009_LOG009.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG009_LOG009.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_logging/mod.rs -snapshot_kind: text --- LOG009.py:4:5: LOG009 [*] Use of undocumented `logging.WARN` constant | 2 | import logging -3 | +3 | 4 | logging.WARN # LOG009 | ^^^^^^^^^^^^ LOG009 5 | logging.WARNING # OK @@ -25,7 +24,7 @@ LOG009.py:4:5: LOG009 [*] Use of undocumented `logging.WARN` constant LOG009.py:11:5: LOG009 [*] Use of undocumented `logging.WARN` constant | 9 | from logging import WARN, WARNING -10 | +10 | 11 | WARN # LOG009 | ^^^^ LOG009 12 | WARNING # OK diff --git a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG015_LOG015.py.snap b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG015_LOG015.py.snap index 717549285d274..6c22e8d998925 100644 --- a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG015_LOG015.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG015_LOG015.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_logging/mod.rs -snapshot_kind: text --- LOG015.py:4:1: LOG015 `debug()` call on root logger | 2 | import logging -3 | +3 | 4 | logging.debug("Lorem") | ^^^^^^^^^^^^^^^^^^^^^^ LOG015 5 | logging.info("ipsum") @@ -89,7 +88,7 @@ LOG015.py:11:1: LOG015 `exception()` call on root logger LOG015.py:26:1: LOG015 `debug()` call on root logger | 24 | ) -25 | +25 | 26 | debug("Lorem") | ^^^^^^^^^^^^^^ LOG015 27 | info("ipsum") diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G001.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G001.py.snap index 2eec8bb3ba90a..a872a12c9db0c 100644 --- a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G001.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G001.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs -snapshot_kind: text --- G001.py:4:14: G001 Logging statement uses `str.format` | 2 | import logging as foo -3 | +3 | 4 | logging.info("Hello {}".format("World!")) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 5 | logging.log(logging.INFO, "Hello {}".format("World!")) @@ -56,14 +55,14 @@ G001.py:9:17: G001 Logging statement uses `str.format` 8 | logging.log(level=logging.INFO, msg="Hello {}".format("World!")) 9 | logging.log(msg="Hello {}".format("World!"), level=logging.INFO) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 -10 | +10 | 11 | # Flask support | G001.py:16:31: G001 Logging statement uses `str.format` | 14 | from flask import current_app as app -15 | +15 | 16 | flask.current_app.logger.info("Hello {}".format("World!")) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 17 | current_app.logger.info("Hello {}".format("World!")) @@ -84,14 +83,14 @@ G001.py:18:30: G001 Logging statement uses `str.format` 17 | current_app.logger.info("Hello {}".format("World!")) 18 | app.logger.log(logging.INFO, "Hello {}".format("World!")) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 -19 | +19 | 20 | from logging import info, log | G001.py:22:6: G001 Logging statement uses `str.format` | 20 | from logging import info, log -21 | +21 | 22 | info("Hello {}".format("World!")) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 23 | log(logging.INFO, "Hello {}".format("World!")) diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G002.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G002.py.snap index 4867dc9276f54..ac9571bbc3ba2 100644 --- a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G002.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G002.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs -snapshot_kind: text --- G002.py:3:14: G002 Logging statement uses `%` | 1 | import logging -2 | +2 | 3 | logging.info("Hello %s" % "World!") | ^^^^^^^^^^^^^^^^^^^^^ G002 4 | logging.log(logging.INFO, "Hello %s" % "World!") @@ -16,14 +15,14 @@ G002.py:4:27: G002 Logging statement uses `%` 3 | logging.info("Hello %s" % "World!") 4 | logging.log(logging.INFO, "Hello %s" % "World!") | ^^^^^^^^^^^^^^^^^^^^^ G002 -5 | +5 | 6 | from logging import info, log | G002.py:8:6: G002 Logging statement uses `%` | 6 | from logging import info, log -7 | +7 | 8 | info("Hello %s" % "World!") | ^^^^^^^^^^^^^^^^^^^^^ G002 9 | log(logging.INFO, "Hello %s" % "World!") diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G003.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G003.py.snap index 28c83697c6d1b..431d5dbf323f2 100644 --- a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G003.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G003.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs -snapshot_kind: text --- G003.py:3:14: G003 Logging statement uses `+` | 1 | import logging -2 | +2 | 3 | logging.info("Hello" + " " + "World!") | ^^^^^^^^^^^^^^^^^^^^^^^^ G003 4 | logging.log(logging.INFO, "Hello" + " " + "World!") @@ -16,14 +15,14 @@ G003.py:4:27: G003 Logging statement uses `+` 3 | logging.info("Hello" + " " + "World!") 4 | logging.log(logging.INFO, "Hello" + " " + "World!") | ^^^^^^^^^^^^^^^^^^^^^^^^ G003 -5 | +5 | 6 | from logging import info, log | G003.py:8:6: G003 Logging statement uses `+` | 6 | from logging import info, log -7 | +7 | 8 | info("Hello" + " " + "World!") | ^^^^^^^^^^^^^^^^^^^^^^^^ G003 9 | log(logging.INFO, "Hello" + " " + "World!") diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G004.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G004.py.snap index 41f4929b78b89..9cd4524dd90e9 100644 --- a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G004.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G004.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs -snapshot_kind: text --- G004.py:4:14: G004 Logging statement uses f-string | @@ -16,7 +15,7 @@ G004.py:5:27: G004 Logging statement uses f-string 4 | logging.info(f"Hello {name}") 5 | logging.log(logging.INFO, f"Hello {name}") | ^^^^^^^^^^^^^^^ G004 -6 | +6 | 7 | _LOGGER = logging.getLogger() | @@ -25,24 +24,24 @@ G004.py:8:14: G004 Logging statement uses f-string 7 | _LOGGER = logging.getLogger() 8 | _LOGGER.info(f"{__name__}") | ^^^^^^^^^^^^^ G004 - 9 | + 9 | 10 | logging.getLogger().info(f"{name}") | G004.py:10:26: G004 Logging statement uses f-string | 8 | _LOGGER.info(f"{__name__}") - 9 | + 9 | 10 | logging.getLogger().info(f"{name}") | ^^^^^^^^^ G004 -11 | +11 | 12 | from logging import info | G004.py:14:6: G004 Logging statement uses f-string | 12 | from logging import info -13 | +13 | 14 | info(f"{name}") | ^^^^^^^^^ G004 15 | info(f"{__name__}") diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G010.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G010.py.snap index a35bf737c4e4f..f746582a16b69 100644 --- a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G010.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G010.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs -snapshot_kind: text --- G010.py:6:9: G010 [*] Logging statement uses `warn` instead of `warning` | 4 | from logging_setup import logger -5 | +5 | 6 | logging.warn("Hello World!") | ^^^^ G010 7 | log.warn("Hello world!") # This shouldn't be considered as a logger candidate @@ -29,7 +28,7 @@ G010.py:8:8: G010 [*] Logging statement uses `warn` instead of `warning` 7 | log.warn("Hello world!") # This shouldn't be considered as a logger candidate 8 | logger.warn("Hello world!") | ^^^^ G010 - 9 | + 9 | 10 | logging . warn("Hello World!") | = help: Convert to `warning` @@ -47,10 +46,10 @@ G010.py:8:8: G010 [*] Logging statement uses `warn` instead of `warning` G010.py:10:11: G010 [*] Logging statement uses `warn` instead of `warning` | 8 | logger.warn("Hello world!") - 9 | + 9 | 10 | logging . warn("Hello World!") | ^^^^ G010 -11 | +11 | 12 | from logging import warn, warning, exception | = help: Convert to `warning` diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G201.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G201.py.snap index abc5d867f978c..62ce1845b6660 100644 --- a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G201.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G201.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs -snapshot_kind: text --- G201.py:8:13: G201 Logging `.exception(...)` should be used instead of `.error(..., exc_info=True)` | @@ -8,7 +7,7 @@ G201.py:8:13: G201 Logging `.exception(...)` should be used instead of `.error(. 7 | except: 8 | logging.error("Hello World", exc_info=True) | ^^^^^ G201 - 9 | + 9 | 10 | try: | @@ -18,7 +17,7 @@ G201.py:13:13: G201 Logging `.exception(...)` should be used instead of `.error( 12 | except: 13 | logging.error("Hello World", exc_info=sys.exc_info()) | ^^^^^ G201 -14 | +14 | 15 | # OK | @@ -28,7 +27,7 @@ G201.py:28:5: G201 Logging `.exception(...)` should be used instead of `.error(. 27 | except: 28 | error("Hello World", exc_info=True) | ^^^^^ G201 -29 | +29 | 30 | try: | @@ -38,6 +37,6 @@ G201.py:33:5: G201 Logging `.exception(...)` should be used instead of `.error(. 32 | except: 33 | error("Hello World", exc_info=sys.exc_info()) | ^^^^^ G201 -34 | +34 | 35 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G202.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G202.py.snap index 8a76df5965f9d..fa50225852831 100644 --- a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G202.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G202.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs -snapshot_kind: text --- G202.py:8:38: G202 Logging statement has redundant `exc_info` | @@ -8,7 +7,7 @@ G202.py:8:38: G202 Logging statement has redundant `exc_info` 7 | except: 8 | logging.exception("Hello World", exc_info=True) | ^^^^^^^^^^^^^ G202 - 9 | + 9 | 10 | try: | @@ -18,7 +17,7 @@ G202.py:13:38: G202 Logging statement has redundant `exc_info` 12 | except: 13 | logging.exception("Hello World", exc_info=sys.exc_info()) | ^^^^^^^^^^^^^^^^^^^^^^^ G202 -14 | +14 | 15 | # OK | @@ -28,7 +27,7 @@ G202.py:28:30: G202 Logging statement has redundant `exc_info` 27 | except: 28 | exception("Hello World", exc_info=True) | ^^^^^^^^^^^^^ G202 -29 | +29 | 30 | try: | @@ -38,6 +37,6 @@ G202.py:33:30: G202 Logging statement has redundant `exc_info` 32 | except: 33 | exception("Hello World", exc_info=sys.exc_info()) | ^^^^^^^^^^^^^^^^^^^^^^^ G202 -34 | +34 | 35 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE790_PIE790.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE790_PIE790.py.snap index bda688be365ea..8fcca36699435 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE790_PIE790.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE790_PIE790.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pie/mod.rs -snapshot_kind: text --- PIE790.py:4:5: PIE790 [*] Unnecessary `pass` statement | 2 | """buzz""" -3 | +3 | 4 | pass | ^^^^ PIE790 | @@ -132,7 +131,7 @@ PIE790.py:42:5: PIE790 [*] Unnecessary `pass` statement PIE790.py:50:5: PIE790 [*] Unnecessary `pass` statement | 48 | """ -49 | +49 | 50 | pass | ^^^^ PIE790 | @@ -150,7 +149,7 @@ PIE790.py:50:5: PIE790 [*] Unnecessary `pass` statement PIE790.py:58:5: PIE790 [*] Unnecessary `pass` statement | 56 | """ -57 | +57 | 58 | pass | ^^^^ PIE790 | @@ -209,7 +208,7 @@ PIE790.py:79:5: PIE790 [*] Unnecessary `pass` statement 78 | """buzz""" 79 | pass | ^^^^ PIE790 -80 | +80 | 81 | async for _ in range(10): | = help: Remove unnecessary `pass` @@ -229,7 +228,7 @@ PIE790.py:83:5: PIE790 [*] Unnecessary `pass` statement 82 | """buzz""" 83 | pass | ^^^^ PIE790 -84 | +84 | 85 | while cond: | = help: Remove unnecessary `pass` @@ -267,7 +266,7 @@ PIE790.py:92:5: PIE790 [*] Unnecessary `pass` statement 91 | """buzz""" 92 | pass | ^^^^ PIE790 -93 | +93 | 94 | async with bar: | = help: Remove unnecessary `pass` @@ -378,7 +377,7 @@ PIE790.py:141:5: PIE790 [*] Unnecessary `pass` statement 140 | pass 141 | pass | ^^^^ PIE790 -142 | +142 | 143 | for i in range(10): | = help: Remove unnecessary `pass` @@ -397,7 +396,7 @@ PIE790.py:144:5: PIE790 [*] Unnecessary `pass` statement 143 | for i in range(10): 144 | pass | ^^^^ PIE790 -145 | +145 | 146 | pass | = help: Remove unnecessary `pass` @@ -414,10 +413,10 @@ PIE790.py:144:5: PIE790 [*] Unnecessary `pass` statement PIE790.py:146:5: PIE790 [*] Unnecessary `pass` statement | 144 | pass -145 | +145 | 146 | pass | ^^^^ PIE790 -147 | +147 | 148 | for i in range(10): | = help: Remove unnecessary `pass` @@ -528,7 +527,7 @@ PIE790.py:166:5: PIE790 [*] Unnecessary `...` literal 165 | ... 166 | ... | ^^^ PIE790 -167 | +167 | 168 | for i in range(10): | = help: Remove unnecessary `...` @@ -547,7 +546,7 @@ PIE790.py:169:5: PIE790 [*] Unnecessary `...` literal 168 | for i in range(10): 169 | ... | ^^^ PIE790 -170 | +170 | 171 | ... | = help: Remove unnecessary `...` @@ -564,10 +563,10 @@ PIE790.py:169:5: PIE790 [*] Unnecessary `...` literal PIE790.py:171:5: PIE790 [*] Unnecessary `...` literal | 169 | ... -170 | +170 | 171 | ... | ^^^ PIE790 -172 | +172 | 173 | for i in range(10): | = help: Remove unnecessary `...` @@ -606,7 +605,7 @@ PIE790.py:175:5: PIE790 [*] Unnecessary `...` literal 174 | ... # comment 175 | ... | ^^^ PIE790 -176 | +176 | 177 | for i in range(10): | = help: Remove unnecessary `...` @@ -644,7 +643,7 @@ PIE790.py:179:5: PIE790 [*] Unnecessary `pass` statement 178 | ... 179 | pass | ^^^^ PIE790 -180 | +180 | 181 | from typing import Protocol | = help: Remove unnecessary `pass` diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE794_PIE794.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE794_PIE794.py.snap index 38c05b1b79fb8..3e6e4df3d580b 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE794_PIE794.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE794_PIE794.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pie/mod.rs -snapshot_kind: text --- PIE794.py:4:5: PIE794 [*] Class field `name` is defined multiple times | @@ -8,7 +7,7 @@ PIE794.py:4:5: PIE794 [*] Class field `name` is defined multiple times 3 | # .... 4 | name = StringField() # PIE794 | ^^^^^^^^^^^^^^^^^^^^ PIE794 -5 | +5 | 6 | def remove(self) -> None: | = help: Remove duplicate field definition for `name` @@ -28,7 +27,7 @@ PIE794.py:13:5: PIE794 [*] Class field `name` is defined multiple times 12 | # .... 13 | name = StringField() # PIE794 | ^^^^^^^^^^^^^^^^^^^^ PIE794 -14 | +14 | 15 | def foo(self) -> None: | = help: Remove duplicate field definition for `name` diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE800_PIE800.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE800_PIE800.py.snap index e63cf00f6a4a1..65449396c05c5 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE800_PIE800.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE800_PIE800.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_pie/mod.rs -snapshot_kind: text --- PIE800.py:1:14: PIE800 [*] Unnecessary spread `**` | 1 | {"foo": 1, **{"bar": 1}} # PIE800 | ^^^^^^^^^^ PIE800 -2 | +2 | 3 | {**{"bar": 10}, "a": "b"} # PIE800 | = help: Remove unnecessary dict @@ -14,69 +13,69 @@ PIE800.py:1:14: PIE800 [*] Unnecessary spread `**` ℹ Safe fix 1 |-{"foo": 1, **{"bar": 1}} # PIE800 1 |+{"foo": 1, "bar": 1} # PIE800 -2 2 | +2 2 | 3 3 | {**{"bar": 10}, "a": "b"} # PIE800 -4 4 | +4 4 | PIE800.py:3:4: PIE800 [*] Unnecessary spread `**` | 1 | {"foo": 1, **{"bar": 1}} # PIE800 -2 | +2 | 3 | {**{"bar": 10}, "a": "b"} # PIE800 | ^^^^^^^^^^^ PIE800 -4 | +4 | 5 | foo({**foo, **{"bar": True}}) # PIE800 | = help: Remove unnecessary dict ℹ Safe fix 1 1 | {"foo": 1, **{"bar": 1}} # PIE800 -2 2 | +2 2 | 3 |-{**{"bar": 10}, "a": "b"} # PIE800 3 |+{"bar": 10, "a": "b"} # PIE800 -4 4 | +4 4 | 5 5 | foo({**foo, **{"bar": True}}) # PIE800 -6 6 | +6 6 | PIE800.py:5:15: PIE800 [*] Unnecessary spread `**` | 3 | {**{"bar": 10}, "a": "b"} # PIE800 -4 | +4 | 5 | foo({**foo, **{"bar": True}}) # PIE800 | ^^^^^^^^^^^^^ PIE800 -6 | +6 | 7 | {**foo, **{"bar": 10}} # PIE800 | = help: Remove unnecessary dict ℹ Safe fix -2 2 | +2 2 | 3 3 | {**{"bar": 10}, "a": "b"} # PIE800 -4 4 | +4 4 | 5 |-foo({**foo, **{"bar": True}}) # PIE800 5 |+foo({**foo, "bar": True}) # PIE800 -6 6 | +6 6 | 7 7 | {**foo, **{"bar": 10}} # PIE800 -8 8 | +8 8 | PIE800.py:7:11: PIE800 [*] Unnecessary spread `**` | 5 | foo({**foo, **{"bar": True}}) # PIE800 -6 | +6 | 7 | {**foo, **{"bar": 10}} # PIE800 | ^^^^^^^^^^^ PIE800 -8 | +8 | 9 | { # PIE800 | = help: Remove unnecessary dict ℹ Safe fix -4 4 | +4 4 | 5 5 | foo({**foo, **{"bar": True}}) # PIE800 -6 6 | +6 6 | 7 |-{**foo, **{"bar": 10}} # PIE800 7 |+{**foo, "bar": 10} # PIE800 -8 8 | +8 8 | 9 9 | { # PIE800 10 10 | "a": "b", @@ -100,7 +99,7 @@ PIE800.py:12:7: PIE800 [*] Unnecessary spread `**` 10 10 | "a": "b", 11 11 | # Preserve 12 |- **{ - 12 |+ + 12 |+ 13 13 | # all 14 |- "bar": 10, # the 14 |+ "bar": 10 # the @@ -108,16 +107,16 @@ PIE800.py:12:7: PIE800 [*] Unnecessary spread `**` 16 |- }, 16 |+ , 17 17 | } -18 18 | +18 18 | 19 19 | {**foo, **buzz, **{bar: 10}} # PIE800 PIE800.py:19:19: PIE800 [*] Unnecessary spread `**` | 17 | } -18 | +18 | 19 | {**foo, **buzz, **{bar: 10}} # PIE800 | ^^^^^^^^^ PIE800 -20 | +20 | 21 | # https://github.com/astral-sh/ruff/issues/15366 | = help: Remove unnecessary dict @@ -125,10 +124,10 @@ PIE800.py:19:19: PIE800 [*] Unnecessary spread `**` ℹ Safe fix 16 16 | }, 17 17 | } -18 18 | +18 18 | 19 |-{**foo, **buzz, **{bar: 10}} # PIE800 19 |+{**foo, **buzz, bar: 10} # PIE800 -20 20 | +20 20 | 21 21 | # https://github.com/astral-sh/ruff/issues/15366 22 22 | { @@ -149,7 +148,7 @@ PIE800.py:24:8: PIE800 [*] Unnecessary spread `**` 24 |- **({"count": 1 if include_count else {}}), 24 |+ "count": 1 if include_count else {}, 25 25 | } -26 26 | +26 26 | 27 27 | { PIE800.py:30:9: PIE800 [*] Unnecessary spread `**` @@ -165,7 +164,7 @@ PIE800.py:30:9: PIE800 [*] Unnecessary spread `**` = help: Remove unnecessary dict ℹ Safe fix -26 26 | +26 26 | 27 27 | { 28 28 | "data": [], 29 |- **( # Comment @@ -175,7 +174,7 @@ PIE800.py:30:9: PIE800 [*] Unnecessary spread `**` 30 |+ # Comment 31 |+ "count": 1 if include_count else {}, 32 32 | } -33 33 | +33 33 | 34 34 | { PIE800.py:37:9: PIE800 [*] Unnecessary spread `**` @@ -191,17 +190,17 @@ PIE800.py:37:9: PIE800 [*] Unnecessary spread `**` = help: Remove unnecessary dict ℹ Safe fix -33 33 | +33 33 | 34 34 | { 35 35 | "data": [], 36 |- **( 37 |- { 38 |- "count": (a := 1),}), - 36 |+ - 37 |+ + 36 |+ + 37 |+ 38 |+ "count": (a := 1), 39 39 | } -40 40 | +40 40 | 41 41 | { PIE800.py:44:9: PIE800 [*] Unnecessary spread `**` @@ -219,21 +218,21 @@ PIE800.py:44:9: PIE800 [*] Unnecessary spread `**` = help: Remove unnecessary dict ℹ Safe fix -40 40 | +40 40 | 41 41 | { 42 42 | "data": [], 43 |- **( 44 |- { - 43 |+ - 44 |+ + 43 |+ + 44 |+ 45 45 | "count": (a := 1) 46 |- } 47 |- ) - 46 |+ - 47 |+ + 46 |+ + 47 |+ 48 48 | , 49 49 | } -50 50 | +50 50 | PIE800.py:54:9: PIE800 [*] Unnecessary spread `**` | @@ -250,7 +249,7 @@ PIE800.py:54:9: PIE800 [*] Unnecessary spread `**` = help: Remove unnecessary dict ℹ Safe fix -50 50 | +50 50 | 51 51 | { 52 52 | "data": [], 53 |- **( @@ -258,14 +257,14 @@ PIE800.py:54:9: PIE800 [*] Unnecessary spread `**` 55 |- "count": (a := 1), # Comment 56 |- } # Comment 57 |- ) # Comment - 53 |+ - 54 |+ + 53 |+ + 54 |+ 55 |+ "count": (a := 1) # Comment 56 |+ # Comment 57 |+ # Comment 58 58 | , 59 59 | } -60 60 | +60 60 | PIE800.py:65:1: PIE800 [*] Unnecessary spread `**` | @@ -281,7 +280,7 @@ PIE800.py:65:1: PIE800 [*] Unnecessary spread `**` = help: Remove unnecessary dict ℹ Safe fix -60 60 | +60 60 | 61 61 | ({ 62 62 | "data": [], 63 |- **( # Comment @@ -296,7 +295,7 @@ PIE800.py:65:1: PIE800 [*] Unnecessary spread `**` 65 |+ # Comment 66 |+ "count": (a := 1) # Comment 67 |+ # Comment - 68 |+ + 68 |+ 69 |+ # Comment 70 70 | , 71 71 | }) diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE804_PIE804.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE804_PIE804.py.snap index 0e21639f56bc3..b26502fe8ccf7 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE804_PIE804.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE804_PIE804.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_pie/mod.rs -snapshot_kind: text --- PIE804.py:1:5: PIE804 [*] Unnecessary `dict` kwargs | 1 | foo(**{"bar": True}) # PIE804 | ^^^^^^^^^^^^^^^ PIE804 -2 | +2 | 3 | foo(**{"r2d2": True}) # PIE804 | = help: Remove unnecessary kwargs @@ -21,10 +20,10 @@ PIE804.py:1:5: PIE804 [*] Unnecessary `dict` kwargs PIE804.py:3:5: PIE804 [*] Unnecessary `dict` kwargs | 1 | foo(**{"bar": True}) # PIE804 -2 | +2 | 3 | foo(**{"r2d2": True}) # PIE804 | ^^^^^^^^^^^^^^^^ PIE804 -4 | +4 | 5 | Foo.objects.create(**{"bar": True}) # PIE804 | = help: Remove unnecessary kwargs @@ -41,10 +40,10 @@ PIE804.py:3:5: PIE804 [*] Unnecessary `dict` kwargs PIE804.py:5:20: PIE804 [*] Unnecessary `dict` kwargs | 3 | foo(**{"r2d2": True}) # PIE804 -4 | +4 | 5 | Foo.objects.create(**{"bar": True}) # PIE804 | ^^^^^^^^^^^^^^^ PIE804 -6 | +6 | 7 | Foo.objects.create(**{"_id": some_id}) # PIE804 | = help: Remove unnecessary kwargs @@ -62,10 +61,10 @@ PIE804.py:5:20: PIE804 [*] Unnecessary `dict` kwargs PIE804.py:7:20: PIE804 [*] Unnecessary `dict` kwargs | 5 | Foo.objects.create(**{"bar": True}) # PIE804 -6 | +6 | 7 | Foo.objects.create(**{"_id": some_id}) # PIE804 | ^^^^^^^^^^^^^^^^^^ PIE804 -8 | +8 | 9 | Foo.objects.create(**{**bar}) # PIE804 | = help: Remove unnecessary kwargs @@ -83,10 +82,10 @@ PIE804.py:7:20: PIE804 [*] Unnecessary `dict` kwargs PIE804.py:9:20: PIE804 [*] Unnecessary `dict` kwargs | 7 | Foo.objects.create(**{"_id": some_id}) # PIE804 - 8 | + 8 | 9 | Foo.objects.create(**{**bar}) # PIE804 | ^^^^^^^^^ PIE804 -10 | +10 | 11 | foo(**{}) | = help: Remove unnecessary kwargs @@ -104,10 +103,10 @@ PIE804.py:9:20: PIE804 [*] Unnecessary `dict` kwargs PIE804.py:11:5: PIE804 [*] Unnecessary `dict` kwargs | 9 | Foo.objects.create(**{**bar}) # PIE804 -10 | +10 | 11 | foo(**{}) | ^^^^ PIE804 -12 | +12 | 13 | foo(**{**data, "foo": "buzz"}) | = help: Remove unnecessary kwargs @@ -128,7 +127,7 @@ PIE804.py:22:5: PIE804 [*] Unnecessary `dict` kwargs 21 | abc(**{"for": 3}) 22 | foo(**{},) | ^^^^ PIE804 -23 | +23 | 24 | # Duplicated key names won't be fixed, to avoid syntax errors. | = help: Remove unnecessary kwargs @@ -167,7 +166,7 @@ PIE804.py:26:10: PIE804 Unnecessary `dict` kwargs 25 | abc(**{'a': b}, **{'a': c}) # PIE804 26 | abc(a=1, **{'a': c}, **{'b': c}) # PIE804 | ^^^^^^^^^^ PIE804 -27 | +27 | 28 | # Some values need to be parenthesized. | = help: Remove unnecessary kwargs @@ -178,7 +177,7 @@ PIE804.py:26:22: PIE804 [*] Unnecessary `dict` kwargs 25 | abc(**{'a': b}, **{'a': c}) # PIE804 26 | abc(a=1, **{'a': c}, **{'b': c}) # PIE804 | ^^^^^^^^^^ PIE804 -27 | +27 | 28 | # Some values need to be parenthesized. | = help: Remove unnecessary kwargs diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE808_PIE808.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE808_PIE808.py.snap index ada350d109a29..86f5cb633258e 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE808_PIE808.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE808_PIE808.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_pie/mod.rs -snapshot_kind: text --- PIE808.py:2:7: PIE808 [*] Unnecessary `start` argument in `range` | 1 | # PIE808 2 | range(0, 10) | ^ PIE808 -3 | +3 | 4 | import builtins | = help: Remove `start` argument @@ -25,7 +24,7 @@ PIE808.py:5:16: PIE808 [*] Unnecessary `start` argument in `range` 4 | import builtins 5 | builtins.range(0, 10) | ^ PIE808 -6 | +6 | 7 | # OK | = help: Remove `start` argument diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE810_PIE810.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE810_PIE810.py.snap index 1084393b531ff..8a23e3ea5341b 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE810_PIE810.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE810_PIE810.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pie/mod.rs -snapshot_kind: text --- PIE810.py:2:1: PIE810 [*] Call `startswith` once with a `tuple` | @@ -89,7 +88,7 @@ PIE810.py:10:1: PIE810 [*] Call `startswith` once with a `tuple` 9 | # error 10 | obj.endswith(foo) or obj.startswith(foo) or obj.startswith("foo") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE810 -11 | +11 | 12 | def func(): | = help: Merge into a single `startswith` call @@ -107,7 +106,7 @@ PIE810.py:10:1: PIE810 [*] Call `startswith` once with a `tuple` PIE810.py:19:8: PIE810 [*] Call `startswith` once with a `tuple` | 17 | z = "w" -18 | +18 | 19 | if msg.startswith(x) or msg.startswith(y) or msg.startswith(z): # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE810 20 | print("yes") @@ -127,7 +126,7 @@ PIE810.py:19:8: PIE810 [*] Call `startswith` once with a `tuple` PIE810.py:25:8: PIE810 [*] Call `startswith` once with a `tuple` | 23 | msg = "hello world" -24 | +24 | 25 | if msg.startswith(("h", "e", "l", "l", "o")) or msg.startswith("h") or msg.startswith("w"): # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE810 26 | print("yes") diff --git a/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T201_T201.py.snap b/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T201_T201.py.snap index 140a3a2f30638..3177ee0830be5 100644 --- a/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T201_T201.py.snap +++ b/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T201_T201.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_print/mod.rs -snapshot_kind: text --- T201.py:4:1: T201 [*] `print` found | 2 | import tempfile -3 | +3 | 4 | print("Hello, world!") # T201 | ^^^^^ T201 5 | print("Hello, world!", file=None) # T201 @@ -66,7 +65,7 @@ T201.py:7:1: T201 [*] `print` found 6 | print("Hello, world!", file=sys.stdout) # T201 7 | print("Hello, world!", file=sys.stderr) # T201 | ^^^^^ T201 -8 | +8 | 9 | with tempfile.NamedTemporaryFile() as fp: | = help: Remove `print` diff --git a/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T203_T203.py.snap b/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T203_T203.py.snap index 72436e24835a3..24d4d7193d794 100644 --- a/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T203_T203.py.snap +++ b/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T203_T203.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_print/mod.rs -snapshot_kind: text --- T203.py:3:1: T203 [*] `pprint` found | 1 | from pprint import pprint -2 | +2 | 3 | pprint("Hello, world!") # T203 | ^^^^^^ T203 -4 | +4 | 5 | import pprint | = help: Remove `pprint` @@ -24,10 +23,10 @@ T203.py:3:1: T203 [*] `pprint` found T203.py:7:1: T203 [*] `pprint` found | 5 | import pprint -6 | +6 | 7 | pprint.pprint("Hello, world!") # T203 | ^^^^^^^^^^^^^ T203 -8 | +8 | 9 | pprint.pformat("Hello, world!") | = help: Remove `pprint` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI001_PYI001.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI001_PYI001.pyi.snap index b692edd2775b0..d612aa2103381 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI001_PYI001.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI001_PYI001.pyi.snap @@ -1,33 +1,32 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI001.pyi:3:5: PYI001 Name of private `TypeVar` must start with `_` | 1 | from typing import ParamSpec, TypeVar, TypeVarTuple -2 | +2 | 3 | T = TypeVar("T") # Error: TypeVars in stubs must start with _ | ^^^^^^^^^^^^ PYI001 -4 | +4 | 5 | TTuple = TypeVarTuple("TTuple") # Error: TypeVarTuples must also start with _ | PYI001.pyi:5:10: PYI001 Name of private `TypeVarTuple` must start with `_` | 3 | T = TypeVar("T") # Error: TypeVars in stubs must start with _ -4 | +4 | 5 | TTuple = TypeVarTuple("TTuple") # Error: TypeVarTuples must also start with _ | ^^^^^^^^^^^^^^^^^^^^^^ PYI001 -6 | +6 | 7 | P = ParamSpec("P") # Error: ParamSpecs must start with _ | PYI001.pyi:7:5: PYI001 Name of private `ParamSpec` must start with `_` | 5 | TTuple = TypeVarTuple("TTuple") # Error: TypeVarTuples must also start with _ -6 | +6 | 7 | P = ParamSpec("P") # Error: ParamSpecs must start with _ | ^^^^^^^^^^^^^^ PYI001 -8 | +8 | 9 | _T = TypeVar("_T") # OK | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI002_PYI002.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI002_PYI002.pyi.snap index c56b6522bb806..7b018399cacde 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI002_PYI002.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI002_PYI002.pyi.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI002.pyi:3:4: PYI002 `if` test must be a simple comparison against `sys.platform` or `sys.version_info` | 1 | import sys -2 | +2 | 3 | if sys.version == 'Python 2.7.10': ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI002 4 | if 'linux' == sys.platform: ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI004_PYI004.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI004_PYI004.pyi.snap index d0c82f0eae236..81182425c2c01 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI004_PYI004.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI004_PYI004.pyi.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI004.pyi:4:4: PYI004 Version comparison must use only major and minor version | 2 | from sys import version_info -3 | +3 | 4 | if sys.version_info >= (3, 4, 3): ... # PYI004 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI004 5 | if sys.version_info < (3, 4, 3): ... # PYI004 @@ -36,6 +35,6 @@ PYI004.pyi:7:4: PYI004 Version comparison must use only major and minor version 6 | if sys.version_info == (3, 4, 3): ... # PYI004 7 | if sys.version_info != (3, 4, 3): ... # PYI004 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI004 -8 | +8 | 9 | if sys.version_info[0] == 2: ... | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI005_PYI005.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI005_PYI005.pyi.snap index 24382f3628466..117c6849485bb 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI005_PYI005.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI005_PYI005.pyi.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI005.pyi:4:4: PYI005 Version comparison must be against a length-1 tuple | 2 | from sys import platform, version_info -3 | +3 | 4 | if sys.version_info[:1] == (2, 7): ... # Y005 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI005 5 | if sys.version_info[:2] == (2,): ... # Y005 diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI006_PYI006.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI006_PYI006.py.snap index a5f79c0998a3c..93cd183f242cd 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI006_PYI006.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI006_PYI006.py.snap @@ -1,51 +1,50 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI006.py:8:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons | 6 | if sys.version_info >= (3, 9): ... # OK - 7 | + 7 | 8 | if sys.version_info == (3, 9): ... # OK | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 - 9 | + 9 | 10 | if sys.version_info == (3, 9): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | PYI006.py:10:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons | 8 | if sys.version_info == (3, 9): ... # OK - 9 | + 9 | 10 | if sys.version_info == (3, 9): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 -11 | +11 | 12 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | PYI006.py:12:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons | 10 | if sys.version_info == (3, 9): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons -11 | +11 | 12 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 -13 | +13 | 14 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | PYI006.py:14:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons | 12 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons -13 | +13 | 14 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 -15 | +15 | 16 | if sys.version_info > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | PYI006.py:16:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons | 14 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons -15 | +15 | 16 | if sys.version_info > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 17 | elif sys.version_info > (3, 11): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons @@ -56,14 +55,14 @@ PYI006.py:17:6: PYI006 Use `<` or `>=` for `sys.version_info` comparisons 16 | if sys.version_info > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons 17 | elif sys.version_info > (3, 11): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 -18 | +18 | 19 | if python_version > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | PYI006.py:19:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons | 17 | elif sys.version_info > (3, 11): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons -18 | +18 | 19 | if python_version > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 20 | elif python_version == (3, 11): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI006_PYI006.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI006_PYI006.pyi.snap index 2ff61307f9468..afe447cc76f5b 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI006_PYI006.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI006_PYI006.pyi.snap @@ -1,51 +1,50 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI006.pyi:8:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons | 6 | if sys.version_info >= (3, 9): ... # OK - 7 | + 7 | 8 | if sys.version_info == (3, 9): ... # OK | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 - 9 | + 9 | 10 | if sys.version_info == (3, 9): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | PYI006.pyi:10:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons | 8 | if sys.version_info == (3, 9): ... # OK - 9 | + 9 | 10 | if sys.version_info == (3, 9): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 -11 | +11 | 12 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | PYI006.pyi:12:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons | 10 | if sys.version_info == (3, 9): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons -11 | +11 | 12 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 -13 | +13 | 14 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | PYI006.pyi:14:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons | 12 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons -13 | +13 | 14 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 -15 | +15 | 16 | if sys.version_info > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | PYI006.pyi:16:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons | 14 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons -15 | +15 | 16 | if sys.version_info > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 17 | elif sys.version_info > (3, 11): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons @@ -56,14 +55,14 @@ PYI006.pyi:17:6: PYI006 Use `<` or `>=` for `sys.version_info` comparisons 16 | if sys.version_info > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons 17 | elif sys.version_info > (3, 11): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 -18 | +18 | 19 | if python_version > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | PYI006.pyi:19:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons | 17 | elif sys.version_info > (3, 11): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons -18 | +18 | 19 | if python_version > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 20 | elif python_version == (3, 11): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI007_PYI007.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI007_PYI007.pyi.snap index 1a8efc340948b..bb46b48b79c4c 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI007_PYI007.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI007_PYI007.pyi.snap @@ -1,31 +1,30 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI007.pyi:7:4: PYI007 Unrecognized `sys.platform` check | 5 | if sys.platform != "platform_name_2": ... # OK -6 | +6 | 7 | if sys.platform in ["linux"]: ... # Error: PYI007 Unrecognized sys.platform check | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI007 -8 | +8 | 9 | if sys.platform > 3: ... # Error: PYI007 Unrecognized sys.platform check | PYI007.pyi:9:4: PYI007 Unrecognized `sys.platform` check | 7 | if sys.platform in ["linux"]: ... # Error: PYI007 Unrecognized sys.platform check - 8 | + 8 | 9 | if sys.platform > 3: ... # Error: PYI007 Unrecognized sys.platform check | ^^^^^^^^^^^^^^^^ PYI007 -10 | +10 | 11 | if sys.platform == 10.12: ... # Error: PYI007 Unrecognized sys.platform check | PYI007.pyi:11:4: PYI007 Unrecognized `sys.platform` check | 9 | if sys.platform > 3: ... # Error: PYI007 Unrecognized sys.platform check -10 | +10 | 11 | if sys.platform == 10.12: ... # Error: PYI007 Unrecognized sys.platform check | ^^^^^^^^^^^^^^^^^^^^^ PYI007 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI008_PYI008.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI008_PYI008.pyi.snap index 7ce6c888f6100..4e8588c7a3dfe 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI008_PYI008.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI008_PYI008.pyi.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI008.pyi:3:20: PYI008 Unrecognized platform `linus` | 1 | import sys -2 | +2 | 3 | if sys.platform == "linus": ... # Error: PYI008 Unrecognized platform `linus` | ^^^^^^^ PYI008 -4 | +4 | 5 | if sys.platform != "linux": ... # OK | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI009_PYI009.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI009_PYI009.pyi.snap index 20aad76466b5f..48db875d89088 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI009_PYI009.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI009_PYI009.pyi.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI009.pyi:3:5: PYI009 [*] Empty body should contain `...`, not `pass` | @@ -8,7 +7,7 @@ PYI009.pyi:3:5: PYI009 [*] Empty body should contain `...`, not `pass` 2 | def foo(): 3 | pass # ERROR PYI009, since we're in a stub file | ^^^^ PYI009 -4 | +4 | 5 | class Bar: ... # OK | = help: Replace `pass` with `...` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI010_PYI010.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI010_PYI010.pyi.snap index b70e93d11b477..a24482573d5d8 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI010_PYI010.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI010_PYI010.pyi.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI010.pyi:6:5: PYI010 [*] Function body must contain only `...` | 5 | def buzz(): 6 | print("buzz") # ERROR PYI010 | ^^^^^^^^^^^^^ PYI010 -7 | +7 | 8 | def foo2(): | = help: Replace function body with `...` @@ -27,7 +26,7 @@ PYI010.pyi:9:5: PYI010 [*] Function body must contain only `...` 8 | def foo2(): 9 | 123 # ERROR PYI010 | ^^^ PYI010 -10 | +10 | 11 | def bizz(): | = help: Replace function body with `...` @@ -47,7 +46,7 @@ PYI010.pyi:12:5: PYI010 [*] Function body must contain only `...` 11 | def bizz(): 12 | x = 123 # ERROR PYI010 | ^^^^^^^ PYI010 -13 | +13 | 14 | def foo3(): | = help: Replace function body with `...` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI012_PYI012.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI012_PYI012.pyi.snap index dd47bc25a8f1a..580d853e1fa57 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI012_PYI012.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI012_PYI012.pyi.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI012.pyi:5:5: PYI012 [*] Class body must not contain `pass` | @@ -8,7 +7,7 @@ PYI012.pyi:5:5: PYI012 [*] Class body must not contain `pass` 4 | value: int 5 | pass # PYI012 Class body must not contain `pass` | ^^^^ PYI012 -6 | +6 | 7 | class OneAttributeClassRev: | = help: Remove unnecessary `pass` @@ -43,10 +42,10 @@ PYI012.pyi:8:5: PYI012 [*] Class body must not contain `pass` PYI012.pyi:16:5: PYI012 [*] Class body must not contain `pass` | 14 | """ -15 | +15 | 16 | pass # PYI012 Class body must not contain `pass` | ^^^^ PYI012 -17 | +17 | 18 | class NonEmptyChild(Exception): | = help: Remove unnecessary `pass` @@ -66,7 +65,7 @@ PYI012.pyi:20:5: PYI012 [*] Class body must not contain `pass` 19 | value: int 20 | pass # PYI012 Class body must not contain `pass` | ^^^^ PYI012 -21 | +21 | 22 | class NonEmptyChild2(Exception): | = help: Remove unnecessary `pass` @@ -104,7 +103,7 @@ PYI012.pyi:28:5: PYI012 [*] Class body must not contain `pass` 27 | value: int 28 | pass # PYI012 Class body must not contain `pass` | ^^^^ PYI012 -29 | +29 | 30 | def __init__(): | = help: Remove unnecessary `pass` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.py.snap index 50855dac19ab4..d76266722eb85 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI013.py:3:5: PYI013 [*] Non-empty class body must not contain `...` | @@ -76,7 +75,7 @@ PYI013.py:13:5: PYI013 [*] Non-empty class body must not contain `...` PYI013.py:21:5: PYI013 [*] Non-empty class body must not contain `...` | 19 | """ -20 | +20 | 21 | ... | ^^^ PYI013 | @@ -133,7 +132,7 @@ PYI013.py:36:5: PYI013 [*] Non-empty class body must not contain `...` 35 | value: int 36 | ... | ^^^ PYI013 -37 | +37 | 38 | def __init__(): | = help: Remove unnecessary `...` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.pyi.snap index c33018dabc4e8..3fc5a71eb42f3 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.pyi.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI013.pyi:5:5: PYI013 [*] Non-empty class body must not contain `...` | @@ -8,7 +7,7 @@ PYI013.pyi:5:5: PYI013 [*] Non-empty class body must not contain `...` 4 | value: int 5 | ... # Error | ^^^ PYI013 -6 | +6 | 7 | class OneAttributeClass2: | = help: Remove unnecessary `...` @@ -82,7 +81,7 @@ PYI013.pyi:17:5: PYI013 [*] Non-empty class body must not contain `...` 16 | ... 17 | ... # Error | ^^^ PYI013 -18 | +18 | 19 | class DocstringClass: | = help: Remove unnecessary `...` @@ -99,10 +98,10 @@ PYI013.pyi:17:5: PYI013 [*] Non-empty class body must not contain `...` PYI013.pyi:24:5: PYI013 [*] Non-empty class body must not contain `...` | 22 | """ -23 | +23 | 24 | ... # Error | ^^^ PYI013 -25 | +25 | 26 | class NonEmptyChild(Exception): | = help: Remove unnecessary `...` @@ -122,7 +121,7 @@ PYI013.pyi:28:5: PYI013 [*] Non-empty class body must not contain `...` 27 | value: int 28 | ... # Error | ^^^ PYI013 -29 | +29 | 30 | class NonEmptyChild2(Exception): | = help: Remove unnecessary `...` @@ -160,7 +159,7 @@ PYI013.pyi:36:5: PYI013 [*] Non-empty class body must not contain `...` 35 | value: int 36 | ... # Error | ^^^ PYI013 -37 | +37 | 38 | def __init__(): | = help: Remove unnecessary `...` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI015_PYI015.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI015_PYI015.pyi.snap index 8aa3d8f983e74..120743179f50d 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI015_PYI015.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI015_PYI015.pyi.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI015.pyi:44:23: PYI015 [*] Only simple default values allowed for assignments | @@ -216,7 +215,7 @@ PYI015.pyi:55:11: PYI015 [*] Only simple default values allowed for assignments 54 | field24 = b"foo" + b"bar" # Y015 Only simple default values are allowed for assignments 55 | field25 = 5 * 5 # Y015 Only simple default values are allowed for assignments | ^^^^^ PYI015 -56 | +56 | 57 | # We shouldn't emit Y015 within functions | = help: Replace default value with `...` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.py.snap index 0310bb7b2cc94..2133baee9e4d2 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI016.py:7:15: PYI016 [*] Duplicate union member `str` | @@ -884,7 +883,7 @@ PYI016.py:113:61: PYI016 [*] Duplicate union member `list[int]` 112 | # Test case for mixed union type 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]] # Error | ^^^^^^^^^ PYI016 -114 | +114 | 115 | field35: "int | str | int" # Error | = help: Remove duplicate union member `list[int]` @@ -902,7 +901,7 @@ PYI016.py:113:61: PYI016 [*] Duplicate union member `list[int]` PYI016.py:115:23: PYI016 [*] Duplicate union member `int` | 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]] # Error -114 | +114 | 115 | field35: "int | str | int" # Error | ^^^ PYI016 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI017_PYI017.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI017_PYI017.pyi.snap index ad32ef170658a..5bc3532babef1 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI017_PYI017.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI017_PYI017.pyi.snap @@ -1,43 +1,42 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI017.pyi:4:1: PYI017 Stubs should not contain assignments to attributes or multiple targets | 2 | a = var # OK -3 | +3 | 4 | b = c = int # PYI017 | ^^^^^^^^^^^ PYI017 -5 | +5 | 6 | a.b = int # PYI017 | PYI017.pyi:6:1: PYI017 Stubs should not contain assignments to attributes or multiple targets | 4 | b = c = int # PYI017 -5 | +5 | 6 | a.b = int # PYI017 | ^^^^^^^^^ PYI017 -7 | +7 | 8 | d, e = int, str # PYI017 | PYI017.pyi:8:1: PYI017 Stubs should not contain assignments to attributes or multiple targets | 6 | a.b = int # PYI017 - 7 | + 7 | 8 | d, e = int, str # PYI017 | ^^^^^^^^^^^^^^^ PYI017 - 9 | + 9 | 10 | f, g, h = int, str, TypeVar("T") # PYI017 | PYI017.pyi:10:1: PYI017 Stubs should not contain assignments to attributes or multiple targets | 8 | d, e = int, str # PYI017 - 9 | + 9 | 10 | f, g, h = int, str, TypeVar("T") # PYI017 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI017 -11 | +11 | 12 | i: TypeAlias = int | str # OK | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI018_PYI018.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI018_PYI018.py.snap index 48ad913ae57a2..34a9c3305a992 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI018_PYI018.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI018_PYI018.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI018.py:6:1: PYI018 Private TypeVar `_T` is never used | 4 | from typing_extensions import ParamSpec, TypeVarTuple -5 | +5 | 6 | _T = typing.TypeVar("_T") | ^^ PYI018 7 | _Ts = typing_extensions.TypeVarTuple("_Ts") @@ -46,6 +45,6 @@ PYI018.py:10:1: PYI018 Private TypeVarTuple `_Ts2` is never used 9 | _P2 = typing.ParamSpec("_P2") 10 | _Ts2 = TypeVarTuple("_Ts2") | ^^^^ PYI018 -11 | +11 | 12 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI018_PYI018.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI018_PYI018.pyi.snap index 38973cdec6ed8..bb6b4504a10ae 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI018_PYI018.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI018_PYI018.pyi.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI018.pyi:6:1: PYI018 Private TypeVar `_T` is never used | 4 | from typing_extensions import ParamSpec, TypeVarTuple -5 | +5 | 6 | _T = typing.TypeVar("_T") | ^^ PYI018 7 | _Ts = typing_extensions.TypeVarTuple("_Ts") @@ -46,6 +45,6 @@ PYI018.pyi:10:1: PYI018 Private TypeVarTuple `_Ts2` is never used 9 | _P2 = typing.ParamSpec("_P2") 10 | _Ts2 = TypeVarTuple("_Ts2") | ^^^^ PYI018 -11 | +11 | 12 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019.py.snap index d073dea248930..0f8e607150e53 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI019.py:7:62: PYI019 Methods like `__new__` should return `Self` instead of a custom `TypeVar` | @@ -57,57 +56,57 @@ PYI019.py:61:48: PYI019 Methods like `__new__` should return `Self` instead of a 60 | class PEP695Fix: 61 | def __new__[S: PEP695Fix](cls: type[S]) -> S: ... | ^ PYI019 -62 | +62 | 63 | def __init_subclass__[S](cls: type[S]) -> S: ... | PYI019.py:63:47: PYI019 Methods like `__init_subclass__` should return `Self` instead of a custom `TypeVar` | 61 | def __new__[S: PEP695Fix](cls: type[S]) -> S: ... -62 | +62 | 63 | def __init_subclass__[S](cls: type[S]) -> S: ... | ^ PYI019 -64 | +64 | 65 | def __neg__[S: PEP695Fix](self: S) -> S: ... | PYI019.py:65:43: PYI019 Methods like `__neg__` should return `Self` instead of a custom `TypeVar` | 63 | def __init_subclass__[S](cls: type[S]) -> S: ... -64 | +64 | 65 | def __neg__[S: PEP695Fix](self: S) -> S: ... | ^ PYI019 -66 | +66 | 67 | def __pos__[S](self: S) -> S: ... | PYI019.py:67:32: PYI019 Methods like `__pos__` should return `Self` instead of a custom `TypeVar` | 65 | def __neg__[S: PEP695Fix](self: S) -> S: ... -66 | +66 | 67 | def __pos__[S](self: S) -> S: ... | ^ PYI019 -68 | +68 | 69 | def __add__[S: PEP695Fix](self: S, other: S) -> S: ... | PYI019.py:69:53: PYI019 Methods like `__add__` should return `Self` instead of a custom `TypeVar` | 67 | def __pos__[S](self: S) -> S: ... -68 | +68 | 69 | def __add__[S: PEP695Fix](self: S, other: S) -> S: ... | ^ PYI019 -70 | +70 | 71 | def __sub__[S](self: S, other: S) -> S: ... | PYI019.py:71:42: PYI019 Methods like `__sub__` should return `Self` instead of a custom `TypeVar` | 69 | def __add__[S: PEP695Fix](self: S, other: S) -> S: ... -70 | +70 | 71 | def __sub__[S](self: S, other: S) -> S: ... | ^ PYI019 -72 | +72 | 73 | @classmethod | @@ -116,7 +115,7 @@ PYI019.py:74:59: PYI019 Methods like `class_method_bound` should return `Self` i 73 | @classmethod 74 | def class_method_bound[S: PEP695Fix](cls: type[S]) -> S: ... | ^ PYI019 -75 | +75 | 76 | @classmethod | @@ -125,64 +124,64 @@ PYI019.py:77:50: PYI019 Methods like `class_method_unbound` should return `Self` 76 | @classmethod 77 | def class_method_unbound[S](cls: type[S]) -> S: ... | ^ PYI019 -78 | +78 | 79 | def instance_method_bound[S: PEP695Fix](self: S) -> S: ... | PYI019.py:79:57: PYI019 Methods like `instance_method_bound` should return `Self` instead of a custom `TypeVar` | 77 | def class_method_unbound[S](cls: type[S]) -> S: ... -78 | +78 | 79 | def instance_method_bound[S: PEP695Fix](self: S) -> S: ... | ^ PYI019 -80 | +80 | 81 | def instance_method_unbound[S](self: S) -> S: ... | PYI019.py:81:48: PYI019 Methods like `instance_method_unbound` should return `Self` instead of a custom `TypeVar` | 79 | def instance_method_bound[S: PEP695Fix](self: S) -> S: ... -80 | +80 | 81 | def instance_method_unbound[S](self: S) -> S: ... | ^ PYI019 -82 | +82 | 83 | def instance_method_bound_with_another_parameter[S: PEP695Fix](self: S, other: S) -> S: ... | PYI019.py:83:90: PYI019 Methods like `instance_method_bound_with_another_parameter` should return `Self` instead of a custom `TypeVar` | 81 | def instance_method_unbound[S](self: S) -> S: ... -82 | +82 | 83 | def instance_method_bound_with_another_parameter[S: PEP695Fix](self: S, other: S) -> S: ... | ^ PYI019 -84 | +84 | 85 | def instance_method_unbound_with_another_parameter[S](self: S, other: S) -> S: ... | PYI019.py:85:81: PYI019 Methods like `instance_method_unbound_with_another_parameter` should return `Self` instead of a custom `TypeVar` | 83 | def instance_method_bound_with_another_parameter[S: PEP695Fix](self: S, other: S) -> S: ... -84 | +84 | 85 | def instance_method_unbound_with_another_parameter[S](self: S, other: S) -> S: ... | ^ PYI019 -86 | +86 | 87 | def multiple_type_vars[S, *Ts, T](self: S, other: S, /, *args: *Ts, a: T, b: list[T]) -> S: ... | PYI019.py:87:94: PYI019 Methods like `multiple_type_vars` should return `Self` instead of a custom `TypeVar` | 85 | def instance_method_unbound_with_another_parameter[S](self: S, other: S) -> S: ... -86 | +86 | 87 | def multiple_type_vars[S, *Ts, T](self: S, other: S, /, *args: *Ts, a: T, b: list[T]) -> S: ... | ^ PYI019 -88 | +88 | 89 | def mixing_old_and_new_style_type_vars[T](self: _S695, a: T, b: T) -> _S695: ... | PYI019.py:89:75: PYI019 Methods like `mixing_old_and_new_style_type_vars` should return `Self` instead of a custom `TypeVar` | 87 | def multiple_type_vars[S, *Ts, T](self: S, other: S, /, *args: *Ts, a: T, b: list[T]) -> S: ... -88 | +88 | 89 | def mixing_old_and_new_style_type_vars[T](self: _S695, a: T, b: T) -> _S695: ... | ^^^^^ PYI019 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019.pyi.snap index 9ad778be25b40..ecad181bcdc4f 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019.pyi.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI019.pyi:7:62: PYI019 Methods like `__new__` should return `Self` instead of a custom `TypeVar` | @@ -64,7 +63,7 @@ PYI019.pyi:61:48: PYI019 Methods like `__new__` should return `Self` instead of 60 | class PEP695Fix: 61 | def __new__[S: PEP695Fix](cls: type[S]) -> S: ... | ^ PYI019 -62 | +62 | 63 | def __init_subclass__[S](cls: type[S]) -> S: ... | = help: Replace with `Self` @@ -72,10 +71,10 @@ PYI019.pyi:61:48: PYI019 Methods like `__new__` should return `Self` instead of PYI019.pyi:63:47: PYI019 Methods like `__init_subclass__` should return `Self` instead of a custom `TypeVar` | 61 | def __new__[S: PEP695Fix](cls: type[S]) -> S: ... -62 | +62 | 63 | def __init_subclass__[S](cls: type[S]) -> S: ... | ^ PYI019 -64 | +64 | 65 | def __neg__[S: PEP695Fix](self: S) -> S: ... | = help: Replace with `Self` @@ -83,10 +82,10 @@ PYI019.pyi:63:47: PYI019 Methods like `__init_subclass__` should return `Self` i PYI019.pyi:65:43: PYI019 Methods like `__neg__` should return `Self` instead of a custom `TypeVar` | 63 | def __init_subclass__[S](cls: type[S]) -> S: ... -64 | +64 | 65 | def __neg__[S: PEP695Fix](self: S) -> S: ... | ^ PYI019 -66 | +66 | 67 | def __pos__[S](self: S) -> S: ... | = help: Replace with `Self` @@ -94,10 +93,10 @@ PYI019.pyi:65:43: PYI019 Methods like `__neg__` should return `Self` instead of PYI019.pyi:67:32: PYI019 Methods like `__pos__` should return `Self` instead of a custom `TypeVar` | 65 | def __neg__[S: PEP695Fix](self: S) -> S: ... -66 | +66 | 67 | def __pos__[S](self: S) -> S: ... | ^ PYI019 -68 | +68 | 69 | def __add__[S: PEP695Fix](self: S, other: S) -> S: ... | = help: Replace with `Self` @@ -105,10 +104,10 @@ PYI019.pyi:67:32: PYI019 Methods like `__pos__` should return `Self` instead of PYI019.pyi:69:53: PYI019 Methods like `__add__` should return `Self` instead of a custom `TypeVar` | 67 | def __pos__[S](self: S) -> S: ... -68 | +68 | 69 | def __add__[S: PEP695Fix](self: S, other: S) -> S: ... | ^ PYI019 -70 | +70 | 71 | def __sub__[S](self: S, other: S) -> S: ... | = help: Replace with `Self` @@ -116,10 +115,10 @@ PYI019.pyi:69:53: PYI019 Methods like `__add__` should return `Self` instead of PYI019.pyi:71:42: PYI019 Methods like `__sub__` should return `Self` instead of a custom `TypeVar` | 69 | def __add__[S: PEP695Fix](self: S, other: S) -> S: ... -70 | +70 | 71 | def __sub__[S](self: S, other: S) -> S: ... | ^ PYI019 -72 | +72 | 73 | @classmethod | = help: Replace with `Self` @@ -129,7 +128,7 @@ PYI019.pyi:74:59: PYI019 Methods like `class_method_bound` should return `Self` 73 | @classmethod 74 | def class_method_bound[S: PEP695Fix](cls: type[S]) -> S: ... | ^ PYI019 -75 | +75 | 76 | @classmethod | = help: Replace with `Self` @@ -139,7 +138,7 @@ PYI019.pyi:77:50: PYI019 Methods like `class_method_unbound` should return `Self 76 | @classmethod 77 | def class_method_unbound[S](cls: type[S]) -> S: ... | ^ PYI019 -78 | +78 | 79 | def instance_method_bound[S: PEP695Fix](self: S) -> S: ... | = help: Replace with `Self` @@ -147,10 +146,10 @@ PYI019.pyi:77:50: PYI019 Methods like `class_method_unbound` should return `Self PYI019.pyi:79:57: PYI019 Methods like `instance_method_bound` should return `Self` instead of a custom `TypeVar` | 77 | def class_method_unbound[S](cls: type[S]) -> S: ... -78 | +78 | 79 | def instance_method_bound[S: PEP695Fix](self: S) -> S: ... | ^ PYI019 -80 | +80 | 81 | def instance_method_unbound[S](self: S) -> S: ... | = help: Replace with `Self` @@ -158,10 +157,10 @@ PYI019.pyi:79:57: PYI019 Methods like `instance_method_bound` should return `Sel PYI019.pyi:81:48: PYI019 Methods like `instance_method_unbound` should return `Self` instead of a custom `TypeVar` | 79 | def instance_method_bound[S: PEP695Fix](self: S) -> S: ... -80 | +80 | 81 | def instance_method_unbound[S](self: S) -> S: ... | ^ PYI019 -82 | +82 | 83 | def instance_method_bound_with_another_parameter[S: PEP695Fix](self: S, other: S) -> S: ... | = help: Replace with `Self` @@ -169,10 +168,10 @@ PYI019.pyi:81:48: PYI019 Methods like `instance_method_unbound` should return `S PYI019.pyi:83:90: PYI019 Methods like `instance_method_bound_with_another_parameter` should return `Self` instead of a custom `TypeVar` | 81 | def instance_method_unbound[S](self: S) -> S: ... -82 | +82 | 83 | def instance_method_bound_with_another_parameter[S: PEP695Fix](self: S, other: S) -> S: ... | ^ PYI019 -84 | +84 | 85 | def instance_method_unbound_with_another_parameter[S](self: S, other: S) -> S: ... | = help: Replace with `Self` @@ -180,10 +179,10 @@ PYI019.pyi:83:90: PYI019 Methods like `instance_method_bound_with_another_parame PYI019.pyi:85:81: PYI019 Methods like `instance_method_unbound_with_another_parameter` should return `Self` instead of a custom `TypeVar` | 83 | def instance_method_bound_with_another_parameter[S: PEP695Fix](self: S, other: S) -> S: ... -84 | +84 | 85 | def instance_method_unbound_with_another_parameter[S](self: S, other: S) -> S: ... | ^ PYI019 -86 | +86 | 87 | def multiple_type_vars[S, *Ts, T](self: S, other: S, /, *args: *Ts, a: T, b: list[T]) -> S: ... | = help: Replace with `Self` @@ -191,10 +190,10 @@ PYI019.pyi:85:81: PYI019 Methods like `instance_method_unbound_with_another_para PYI019.pyi:87:94: PYI019 Methods like `multiple_type_vars` should return `Self` instead of a custom `TypeVar` | 85 | def instance_method_unbound_with_another_parameter[S](self: S, other: S) -> S: ... -86 | +86 | 87 | def multiple_type_vars[S, *Ts, T](self: S, other: S, /, *args: *Ts, a: T, b: list[T]) -> S: ... | ^ PYI019 -88 | +88 | 89 | def mixing_old_and_new_style_type_vars[T](self: _S695, a: T, b: T) -> _S695: ... | = help: Replace with `Self` @@ -202,7 +201,7 @@ PYI019.pyi:87:94: PYI019 Methods like `multiple_type_vars` should return `Self` PYI019.pyi:89:75: PYI019 Methods like `mixing_old_and_new_style_type_vars` should return `Self` instead of a custom `TypeVar` | 87 | def multiple_type_vars[S, *Ts, T](self: S, other: S, /, *args: *Ts, a: T, b: list[T]) -> S: ... -88 | +88 | 89 | def mixing_old_and_new_style_type_vars[T](self: _S695, a: T, b: T) -> _S695: ... | ^^^^^ PYI019 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI020_PYI020.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI020_PYI020.pyi.snap index 20e2ab752e211..0512085eb1182 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI020_PYI020.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI020_PYI020.pyi.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI020.pyi:7:10: PYI020 [*] Quoted annotations should not be included in stubs | 5 | import typing_extensions -6 | +6 | 7 | def f(x: "int"): ... # Y020 Quoted annotations should never be used in stubs | ^^^^^ PYI020 8 | def g(x: list["int"]): ... # Y020 Quoted annotations should never be used in stubs @@ -48,7 +47,7 @@ PYI020.pyi:9:26: PYI020 [*] Quoted annotations should not be included in stubs 8 | def g(x: list["int"]): ... # Y020 Quoted annotations should never be used in stubs 9 | _T = TypeVar("_T", bound="int") # Y020 Quoted annotations should never be used in stubs | ^^^^^ PYI020 -10 | +10 | 11 | def h(w: Literal["a", "b"], x: typing.Literal["c"], y: typing_extensions.Literal["d"], z: _T) -> _T: ... | = help: Remove quotes @@ -66,7 +65,7 @@ PYI020.pyi:9:26: PYI020 [*] Quoted annotations should not be included in stubs PYI020.pyi:13:12: PYI020 [*] Quoted annotations should not be included in stubs | 11 | def h(w: Literal["a", "b"], x: typing.Literal["c"], y: typing_extensions.Literal["d"], z: _T) -> _T: ... -12 | +12 | 13 | def j() -> "int": ... # Y020 Quoted annotations should never be used in stubs | ^^^^^ PYI020 14 | Alias: TypeAlias = list["int"] # Y020 Quoted annotations should never be used in stubs @@ -88,7 +87,7 @@ PYI020.pyi:14:25: PYI020 [*] Quoted annotations should not be included in stubs 13 | def j() -> "int": ... # Y020 Quoted annotations should never be used in stubs 14 | Alias: TypeAlias = list["int"] # Y020 Quoted annotations should never be used in stubs | ^^^^^ PYI020 -15 | +15 | 16 | class Child(list["int"]): # Y020 Quoted annotations should never be used in stubs | = help: Remove quotes @@ -106,7 +105,7 @@ PYI020.pyi:14:25: PYI020 [*] Quoted annotations should not be included in stubs PYI020.pyi:16:18: PYI020 [*] Quoted annotations should not be included in stubs | 14 | Alias: TypeAlias = list["int"] # Y020 Quoted annotations should never be used in stubs -15 | +15 | 16 | class Child(list["int"]): # Y020 Quoted annotations should never be used in stubs | ^^^^^ PYI020 17 | """Documented and guaranteed useful.""" # Y021 Docstrings should not be included in stubs @@ -170,7 +169,7 @@ PYI020.pyi:24:8: PYI020 [*] Quoted annotations should not be included in stubs 23 | else: 24 | f: "bytes" # Y020 Quoted annotations should never be used in stubs | ^^^^^^^ PYI020 -25 | +25 | 26 | # These two shouldn't trigger Y020 -- empty strings can't be "quoted annotations" | = help: Remove quotes diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI024_PYI024.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI024_PYI024.py.snap index 26a733c659151..98a5e1131ce63 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI024_PYI024.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI024_PYI024.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI024.py:3:9: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` | 1 | import collections -2 | +2 | 3 | person: collections.namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" | ^^^^^^^^^^^^^^^^^^^^^^ PYI024 -4 | +4 | 5 | from collections import namedtuple | = help: Replace with `typing.NamedTuple` @@ -16,10 +15,10 @@ PYI024.py:3:9: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple PYI024.py:7:9: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` | 5 | from collections import namedtuple -6 | +6 | 7 | person: namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" | ^^^^^^^^^^ PYI024 -8 | +8 | 9 | person = namedtuple( | = help: Replace with `typing.NamedTuple` @@ -27,7 +26,7 @@ PYI024.py:7:9: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple PYI024.py:9:10: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` | 7 | person: namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" - 8 | + 8 | 9 | person = namedtuple( | ^^^^^^^^^^ PYI024 10 | "Person", ["name", "age"] diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI024_PYI024.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI024_PYI024.pyi.snap index cb5cf788b53ae..413264f767fb7 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI024_PYI024.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI024_PYI024.pyi.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI024.pyi:3:9: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` | 1 | import collections -2 | +2 | 3 | person: collections.namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" | ^^^^^^^^^^^^^^^^^^^^^^ PYI024 -4 | +4 | 5 | from collections import namedtuple | = help: Replace with `typing.NamedTuple` @@ -16,10 +15,10 @@ PYI024.pyi:3:9: PYI024 Use `typing.NamedTuple` instead of `collections.namedtupl PYI024.pyi:7:9: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` | 5 | from collections import namedtuple -6 | +6 | 7 | person: namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" | ^^^^^^^^^^ PYI024 -8 | +8 | 9 | person = namedtuple( | = help: Replace with `typing.NamedTuple` @@ -27,7 +26,7 @@ PYI024.pyi:7:9: PYI024 Use `typing.NamedTuple` instead of `collections.namedtupl PYI024.pyi:9:10: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` | 7 | person: namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" - 8 | + 8 | 9 | person = namedtuple( | ^^^^^^^^^^ PYI024 10 | "Person", ["name", "age"] diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.py.snap index 441394e41ad94..842c97c533fea 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI025_1.py:10:33: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin | @@ -25,7 +24,7 @@ PYI025_1.py:14:51: PYI025 [*] Use `from collections.abc import Set as AbstractSe 13 | def f(): 14 | from collections.abc import Container, Sized, Set, ValuesView # PYI025 | ^^^ PYI025 -15 | +15 | 16 | GLOBAL: Set[int] = set() | = help: Alias `Set` to `AbstractSet` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.pyi.snap index 04eae2053020a..e5ca3811d2d83 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.pyi.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI025_1.pyi:8:33: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin | 7 | def f(): 8 | from collections.abc import Set # PYI025 | ^^^ PYI025 - 9 | + 9 | 10 | def f(): | = help: Alias `Set` to `AbstractSet` @@ -27,7 +26,7 @@ PYI025_1.pyi:11:51: PYI025 [*] Use `from collections.abc import Set as AbstractS 10 | def f(): 11 | from collections.abc import Container, Sized, Set, ValuesView # PYI025 | ^^^ PYI025 -12 | +12 | 13 | def f(): | = help: Alias `Set` to `AbstractSet` @@ -80,10 +79,10 @@ PYI025_1.pyi:16:37: PYI025 [*] Use `from collections.abc import Set as AbstractS PYI025_1.pyi:33:29: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin | 31 | print(Set) -32 | +32 | 33 | from collections.abc import Set | ^^^ PYI025 -34 | +34 | 35 | def f(): | = help: Alias `Set` to `AbstractSet` @@ -126,7 +125,7 @@ PYI025_1.pyi:44:33: PYI025 [*] Use `from collections.abc import Set as AbstractS 43 | """Test: nonlocal symbol renaming.""" 44 | from collections.abc import Set | ^^^ PYI025 -45 | +45 | 46 | def g(): | = help: Alias `Set` to `AbstractSet` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.py.snap index 31448f859e89c..284fe290194ff 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI025_2.py:3:29: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin | 1 | """Tests to ensure we correctly rename references inside `__all__`""" -2 | +2 | 3 | from collections.abc import Set | ^^^ PYI025 -4 | +4 | 5 | __all__ = ["Set"] | = help: Alias `Set` to `AbstractSet` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.pyi.snap index 3b5be7bd6bee2..88d1423db09ab 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.pyi.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI025_2.pyi:3:29: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin | 1 | """Tests to ensure we correctly rename references inside `__all__`""" -2 | +2 | 3 | from collections.abc import Set | ^^^ PYI025 -4 | +4 | 5 | __all__ = ["Set"] | = help: Alias `Set` to `AbstractSet` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.py.snap index 5d8c7a1004dc8..8e29eb17f31a0 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI025_3.py:6:36: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin | 4 | """ -5 | +5 | 6 | from collections.abc import Set as Set # PYI025 triggered but fix is not marked as safe | ^^^ PYI025 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.pyi.snap index 836003f87e08c..8eb394f20c7c8 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.pyi.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI025_3.pyi:6:36: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin | 4 | """ -5 | +5 | 6 | from collections.abc import Set as Set # PYI025 triggered but fix is not marked as safe | ^^^ PYI025 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI026_PYI026.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI026_PYI026.pyi.snap index 92f63d9f4c0db..b59d96e3d2bfa 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI026_PYI026.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI026_PYI026.pyi.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI026.pyi:3:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `NewAny: TypeAlias = Any` | 1 | from typing import Literal, Any -2 | +2 | 3 | NewAny = Any | ^^^^^^ PYI026 4 | OptionalStr = typing.Optional[str] @@ -96,7 +95,7 @@ PYI026.pyi:7:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `AliasNo 6 | IntOrStr = int | str 7 | AliasNone = None | ^^^^^^^^^ PYI026 -8 | +8 | 9 | NewAny: typing.TypeAlias = Any | = help: Add `TypeAlias` annotation @@ -120,7 +119,7 @@ PYI026.pyi:17:5: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `FLAG_T 16 | class NotAnEnum: 17 | FLAG_THIS = None | ^^^^^^^^^ PYI026 -18 | +18 | 19 | # these are ok | = help: Add `TypeAlias` annotation diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI029_PYI029.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI029_PYI029.pyi.snap index 231615e3b0d1f..fee65011201af 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI029_PYI029.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI029_PYI029.pyi.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI029.pyi:10:9: PYI029 [*] Defining `__str__` in a stub is almost always redundant | 9 | class ShouldRemoveSingle: 10 | def __str__(self) -> builtins.str: ... # Error: PYI029 | ^^^^^^^ PYI029 -11 | +11 | 12 | class ShouldRemove: | = help: Remove definition of `__str__` @@ -46,7 +45,7 @@ PYI029.pyi:14:9: PYI029 [*] Defining `__str__` in a stub is almost always redund 13 | def __repr__(self) -> str: ... # Error: PYI029 14 | def __str__(self) -> builtins.str: ... # Error: PYI029 | ^^^^^^^ PYI029 -15 | +15 | 16 | class NoReturnSpecified: | = help: Remove definition of `__str__` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.py.snap index 6fd27a54704f8..d649aeb619fe5 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI030.py:9:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` | 8 | # Should emit for duplicate field types. 9 | field2: Literal[1] | Literal[2] # Error | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -10 | +10 | 11 | # Should emit for union types in arguments. | = help: Replace with a single `Literal` @@ -127,7 +126,7 @@ PYI030.py:25:9: PYI030 [*] Multiple literal members in a union. Use a single lit 24 | field5: Literal[1] | str | Literal[2] # Error 25 | field6: Literal[1] | bool | Literal[2] | str # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -26 | +26 | 27 | # Should emit for non-type unions. | = help: Replace with a single `Literal` @@ -147,7 +146,7 @@ PYI030.py:28:10: PYI030 [*] Multiple literal members in a union. Use a single li 27 | # Should emit for non-type unions. 28 | field7 = Literal[1] | Literal[2] # Error | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -29 | +29 | 30 | # Should emit for parenthesized unions. | = help: Replace with a single `Literal` @@ -167,7 +166,7 @@ PYI030.py:31:9: PYI030 [*] Multiple literal members in a union. Use a single lit 30 | # Should emit for parenthesized unions. 31 | field8: Literal[1] | (Literal[2] | str) # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -32 | +32 | 33 | # Should handle user parentheses when fixing. | = help: Replace with a single `Literal` @@ -207,7 +206,7 @@ PYI030.py:35:10: PYI030 [*] Multiple literal members in a union. Use a single li 34 | field9: Literal[1] | (Literal[2] | str) # Error 35 | field10: (Literal[1] | str) | Literal[2] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -36 | +36 | 37 | # Should emit for union in generic parent type. | = help: Replace with a single `Literal` @@ -227,7 +226,7 @@ PYI030.py:38:15: PYI030 [*] Multiple literal members in a union. Use a single li 37 | # Should emit for union in generic parent type. 38 | field11: dict[Literal[1] | Literal[2], str] # Error | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -39 | +39 | 40 | # Should emit for unions with more than two cases | = help: Replace with a single `Literal` @@ -267,7 +266,7 @@ PYI030.py:42:10: PYI030 [*] Multiple literal members in a union. Use a single li 41 | field12: Literal[1] | Literal[2] | Literal[3] # Error 42 | field13: Literal[1] | Literal[2] | Literal[3] | Literal[4] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -43 | +43 | 44 | # Should emit for unions with more than two cases, even if not directly adjacent | = help: Replace with a single `Literal` @@ -287,7 +286,7 @@ PYI030.py:45:10: PYI030 [*] Multiple literal members in a union. Use a single li 44 | # Should emit for unions with more than two cases, even if not directly adjacent 45 | field14: Literal[1] | Literal[2] | str | Literal[3] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -46 | +46 | 47 | # Should emit for unions with mixed literal internal types | = help: Replace with a single `Literal` @@ -307,7 +306,7 @@ PYI030.py:48:10: PYI030 [*] Multiple literal members in a union. Use a single li 47 | # Should emit for unions with mixed literal internal types 48 | field15: Literal[1] | Literal["foo"] | Literal[True] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -49 | +49 | 50 | # Shouldn't emit for duplicate field types with same value; covered by Y016 | = help: Replace with a single `Literal` @@ -327,7 +326,7 @@ PYI030.py:51:10: PYI030 [*] Multiple literal members in a union. Use a single li 50 | # Shouldn't emit for duplicate field types with same value; covered by Y016 51 | field16: Literal[1] | Literal[1] # OK | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -52 | +52 | 53 | # Shouldn't emit if in new parent type | = help: Replace with a single `Literal` @@ -347,7 +346,7 @@ PYI030.py:60:10: PYI030 [*] Multiple literal members in a union. Use a single li 59 | # Should respect name of literal type used 60 | field19: typing.Literal[1] | typing.Literal[2] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -61 | +61 | 62 | # Should emit in cases with newlines | = help: Replace with a single `Literal` @@ -373,7 +372,7 @@ PYI030.py:63:10: PYI030 [*] Multiple literal members in a union. Use a single li 67 | | Literal[2], 68 | | ] # Error, newline and comment will not be emitted in message | |_^ PYI030 -69 | +69 | 70 | # Should handle multiple unions with multiple members | = help: Replace with a single `Literal` @@ -398,7 +397,7 @@ PYI030.py:71:10: PYI030 [*] Multiple literal members in a union. Use a single li 70 | # Should handle multiple unions with multiple members 71 | field21: Literal[1, 2] | Literal[3, 4] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -72 | +72 | 73 | # Should emit in cases with `typing.Union` instead of `|` | = help: Replace with a single `Literal` @@ -418,7 +417,7 @@ PYI030.py:74:10: PYI030 [*] Multiple literal members in a union. Use a single li 73 | # Should emit in cases with `typing.Union` instead of `|` 74 | field22: typing.Union[Literal[1], Literal[2]] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -75 | +75 | 76 | # Should emit in cases with `typing_extensions.Literal` | = help: Replace with a single `Literal` @@ -438,7 +437,7 @@ PYI030.py:77:10: PYI030 [*] Multiple literal members in a union. Use a single li 76 | # Should emit in cases with `typing_extensions.Literal` 77 | field23: typing_extensions.Literal[1] | typing_extensions.Literal[2] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -78 | +78 | 79 | # Should emit in cases with nested `typing.Union` | = help: Replace with a single `Literal` @@ -458,7 +457,7 @@ PYI030.py:80:10: PYI030 [*] Multiple literal members in a union. Use a single li 79 | # Should emit in cases with nested `typing.Union` 80 | field24: typing.Union[Literal[1], typing.Union[Literal[2], str]] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -81 | +81 | 82 | # Should emit in cases with mixed `typing.Union` and `|` | = help: Replace with a single `Literal` @@ -478,7 +477,7 @@ PYI030.py:83:10: PYI030 [*] Multiple literal members in a union. Use a single li 82 | # Should emit in cases with mixed `typing.Union` and `|` 83 | field25: typing.Union[Literal[1], Literal[2] | str] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -84 | +84 | 85 | # Should emit only once in cases with multiple nested `typing.Union` | = help: Replace with a single `Literal` @@ -498,7 +497,7 @@ PYI030.py:86:10: PYI030 [*] Multiple literal members in a union. Use a single li 85 | # Should emit only once in cases with multiple nested `typing.Union` 86 | field24: typing.Union[Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]]] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -87 | +87 | 88 | # Should use the first literal subscript attribute when fixing | = help: Replace with a single `Literal` @@ -518,7 +517,7 @@ PYI030.py:89:10: PYI030 [*] Multiple literal members in a union. Use a single li 88 | # Should use the first literal subscript attribute when fixing 89 | field25: typing.Union[typing_extensions.Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]], str] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -90 | +90 | 91 | from typing import IO, Literal | = help: Replace with a single `Literal` @@ -536,7 +535,7 @@ PYI030.py:89:10: PYI030 [*] Multiple literal members in a union. Use a single li PYI030.py:93:16: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal["a", "b"]` | 91 | from typing import IO, Literal -92 | +92 | 93 | InlineOption = Literal["a"] | Literal["b"] | IO[str] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.pyi.snap index ed6b8ce87e3a6..86f3114beb955 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.pyi.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI030.pyi:9:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` | 8 | # Should emit for duplicate field types. 9 | field2: Literal[1] | Literal[2] # Error | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -10 | +10 | 11 | # Should emit for union types in arguments. | = help: Replace with a single `Literal` @@ -127,7 +126,7 @@ PYI030.pyi:25:9: PYI030 [*] Multiple literal members in a union. Use a single li 24 | field5: Literal[1] | str | Literal[2] # Error 25 | field6: Literal[1] | bool | Literal[2] | str # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -26 | +26 | 27 | # Should emit for non-type unions. | = help: Replace with a single `Literal` @@ -147,7 +146,7 @@ PYI030.pyi:28:10: PYI030 [*] Multiple literal members in a union. Use a single l 27 | # Should emit for non-type unions. 28 | field7 = Literal[1] | Literal[2] # Error | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -29 | +29 | 30 | # Should emit for parenthesized unions. | = help: Replace with a single `Literal` @@ -167,7 +166,7 @@ PYI030.pyi:31:9: PYI030 [*] Multiple literal members in a union. Use a single li 30 | # Should emit for parenthesized unions. 31 | field8: Literal[1] | (Literal[2] | str) # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -32 | +32 | 33 | # Should handle user parentheses when fixing. | = help: Replace with a single `Literal` @@ -207,7 +206,7 @@ PYI030.pyi:35:10: PYI030 [*] Multiple literal members in a union. Use a single l 34 | field9: Literal[1] | (Literal[2] | str) # Error 35 | field10: (Literal[1] | str) | Literal[2] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -36 | +36 | 37 | # Should emit for union in generic parent type. | = help: Replace with a single `Literal` @@ -227,7 +226,7 @@ PYI030.pyi:38:15: PYI030 [*] Multiple literal members in a union. Use a single l 37 | # Should emit for union in generic parent type. 38 | field11: dict[Literal[1] | Literal[2], str] # Error | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -39 | +39 | 40 | # Should emit for unions with more than two cases | = help: Replace with a single `Literal` @@ -267,7 +266,7 @@ PYI030.pyi:42:10: PYI030 [*] Multiple literal members in a union. Use a single l 41 | field12: Literal[1] | Literal[2] | Literal[3] # Error 42 | field13: Literal[1] | Literal[2] | Literal[3] | Literal[4] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -43 | +43 | 44 | # Should emit for unions with more than two cases, even if not directly adjacent | = help: Replace with a single `Literal` @@ -287,7 +286,7 @@ PYI030.pyi:45:10: PYI030 [*] Multiple literal members in a union. Use a single l 44 | # Should emit for unions with more than two cases, even if not directly adjacent 45 | field14: Literal[1] | Literal[2] | str | Literal[3] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -46 | +46 | 47 | # Should emit for unions with mixed literal internal types | = help: Replace with a single `Literal` @@ -307,7 +306,7 @@ PYI030.pyi:48:10: PYI030 [*] Multiple literal members in a union. Use a single l 47 | # Should emit for unions with mixed literal internal types 48 | field15: Literal[1] | Literal["foo"] | Literal[True] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -49 | +49 | 50 | # Shouldn't emit for duplicate field types with same value; covered by Y016 | = help: Replace with a single `Literal` @@ -327,7 +326,7 @@ PYI030.pyi:51:10: PYI030 [*] Multiple literal members in a union. Use a single l 50 | # Shouldn't emit for duplicate field types with same value; covered by Y016 51 | field16: Literal[1] | Literal[1] # OK | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -52 | +52 | 53 | # Shouldn't emit if in new parent type | = help: Replace with a single `Literal` @@ -347,7 +346,7 @@ PYI030.pyi:60:10: PYI030 [*] Multiple literal members in a union. Use a single l 59 | # Should respect name of literal type used 60 | field19: typing.Literal[1] | typing.Literal[2] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -61 | +61 | 62 | # Should emit in cases with newlines | = help: Replace with a single `Literal` @@ -373,7 +372,7 @@ PYI030.pyi:63:10: PYI030 [*] Multiple literal members in a union. Use a single l 67 | | Literal[2], 68 | | ] # Error, newline and comment will not be emitted in message | |_^ PYI030 -69 | +69 | 70 | # Should handle multiple unions with multiple members | = help: Replace with a single `Literal` @@ -398,7 +397,7 @@ PYI030.pyi:71:10: PYI030 [*] Multiple literal members in a union. Use a single l 70 | # Should handle multiple unions with multiple members 71 | field21: Literal[1, 2] | Literal[3, 4] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -72 | +72 | 73 | # Should emit in cases with `typing.Union` instead of `|` | = help: Replace with a single `Literal` @@ -418,7 +417,7 @@ PYI030.pyi:74:10: PYI030 [*] Multiple literal members in a union. Use a single l 73 | # Should emit in cases with `typing.Union` instead of `|` 74 | field22: typing.Union[Literal[1], Literal[2]] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -75 | +75 | 76 | # Should emit in cases with `typing_extensions.Literal` | = help: Replace with a single `Literal` @@ -438,7 +437,7 @@ PYI030.pyi:77:10: PYI030 [*] Multiple literal members in a union. Use a single l 76 | # Should emit in cases with `typing_extensions.Literal` 77 | field23: typing_extensions.Literal[1] | typing_extensions.Literal[2] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -78 | +78 | 79 | # Should emit in cases with nested `typing.Union` | = help: Replace with a single `Literal` @@ -458,7 +457,7 @@ PYI030.pyi:80:10: PYI030 [*] Multiple literal members in a union. Use a single l 79 | # Should emit in cases with nested `typing.Union` 80 | field24: typing.Union[Literal[1], typing.Union[Literal[2], str]] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -81 | +81 | 82 | # Should emit in cases with mixed `typing.Union` and `|` | = help: Replace with a single `Literal` @@ -478,7 +477,7 @@ PYI030.pyi:83:10: PYI030 [*] Multiple literal members in a union. Use a single l 82 | # Should emit in cases with mixed `typing.Union` and `|` 83 | field25: typing.Union[Literal[1], Literal[2] | str] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -84 | +84 | 85 | # Should emit only once in cases with multiple nested `typing.Union` | = help: Replace with a single `Literal` @@ -498,7 +497,7 @@ PYI030.pyi:86:10: PYI030 [*] Multiple literal members in a union. Use a single l 85 | # Should emit only once in cases with multiple nested `typing.Union` 86 | field24: typing.Union[Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]]] # Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -87 | +87 | 88 | # Should use the first literal subscript attribute when fixing | = help: Replace with a single `Literal` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI035_PYI035.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI035_PYI035.pyi.snap index ddf4519f8eb68..7a6209c383d22 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI035_PYI035.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI035_PYI035.pyi.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI035.pyi:1:1: PYI035 `__all__` in a stub file must have a value, as it has the same semantics as `__all__` at runtime | 1 | __all__: list[str] # Error: PYI035 | ^^^^^^^^^^^^^^^^^^ PYI035 -2 | +2 | 3 | __all__: list[str] = ["foo"] | @@ -25,6 +24,6 @@ PYI035.pyi:8:5: PYI035 `__slots__` in a stub file must have a value, as it has t 7 | __match_args__: tuple[str, ...] # Error: PYI035 8 | __slots__: tuple[str, ...] # Error: PYI035 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI035 - 9 | + 9 | 10 | class Bar: | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI042_PYI042.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI042_PYI042.py.snap index fee16d7b5529e..f4b565480be92 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI042_PYI042.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI042_PYI042.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI042.py:10:1: PYI042 Type alias `just_literals_pipe_union` should be CamelCase | 8 | ) - 9 | + 9 | 10 | just_literals_pipe_union: TypeAlias = ( | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI042 11 | Literal[True] | Literal["idk"] @@ -15,7 +14,7 @@ PYI042.py:10:1: PYI042 Type alias `just_literals_pipe_union` should be CamelCase PYI042.py:19:1: PYI042 Type alias `snake_case_alias1` should be CamelCase | 17 | _PrivateAliasS2: TypeAlias = Annotated[str, "also okay"] -18 | +18 | 19 | snake_case_alias1: TypeAlias = str | int # PYI042, since not camel case | ^^^^^^^^^^^^^^^^^ PYI042 20 | _snake_case_alias2: TypeAlias = Literal["whatever"] # PYI042, since not camel case diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI042_PYI042.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI042_PYI042.pyi.snap index 44d9636fca76e..7e1457c68b024 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI042_PYI042.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI042_PYI042.pyi.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI042.pyi:10:1: PYI042 Type alias `just_literals_pipe_union` should be CamelCase | 8 | ) - 9 | + 9 | 10 | just_literals_pipe_union: TypeAlias = ( | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI042 11 | Literal[True] | Literal["idk"] @@ -15,7 +14,7 @@ PYI042.pyi:10:1: PYI042 Type alias `just_literals_pipe_union` should be CamelCas PYI042.pyi:19:1: PYI042 Type alias `snake_case_alias1` should be CamelCase | 17 | _PrivateAliasS2: TypeAlias = Annotated[str, "also okay"] -18 | +18 | 19 | snake_case_alias1: TypeAlias = str | int # PYI042, since not camel case | ^^^^^^^^^^^^^^^^^ PYI042 20 | _snake_case_alias2: TypeAlias = Literal["whatever"] # PYI042, since not camel case diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI043_PYI043.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI043_PYI043.py.snap index 8fa3be2dda65f..d9a02f87e47bc 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI043_PYI043.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI043_PYI043.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI043.py:10:1: PYI043 Private type alias `_PrivateAliasT` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) | 8 | ) - 9 | + 9 | 10 | _PrivateAliasT: TypeAlias = str | int # PYI043, since this ends in a T | ^^^^^^^^^^^^^^ PYI043 11 | _PrivateAliasT2: TypeAlias = typing.Any # PYI043, since this ends in a T diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI043_PYI043.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI043_PYI043.pyi.snap index 1b98a7729be54..81526e74634d8 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI043_PYI043.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI043_PYI043.pyi.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI043.pyi:10:1: PYI043 Private type alias `_PrivateAliasT` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) | 8 | ) - 9 | + 9 | 10 | _PrivateAliasT: TypeAlias = str | int # PYI043, since this ends in a T | ^^^^^^^^^^^^^^ PYI043 11 | _PrivateAliasT2: TypeAlias = typing.Any # PYI043, since this ends in a T diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI044_PYI044.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI044_PYI044.pyi.snap index d1595c40da2bf..bb018c27edb74 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI044_PYI044.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI044_PYI044.pyi.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI044.pyi:2:1: PYI044 `from __future__ import annotations` has no effect in stub files, since type checkers automatically treat stubs as having those semantics | @@ -17,7 +16,7 @@ PYI044.pyi:3:1: PYI044 `from __future__ import annotations` has no effect in stu 2 | from __future__ import annotations # PYI044. 3 | from __future__ import annotations, with_statement # PYI044. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI044 -4 | +4 | 5 | # Good imports. | = help: Remove `from __future__ import annotations` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI045_PYI045.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI045_PYI045.pyi.snap index 09b485db0bc09..bca6451be568b 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI045_PYI045.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI045_PYI045.pyi.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI045.pyi:9:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` | @@ -39,7 +38,7 @@ PYI045.pyi:25:27: PYI045 `__iter__` methods should return an `Iterator`, not an 24 | class IterableReturn: 25 | def __iter__(self) -> Iterable: ... # Error: PYI045 | ^^^^^^^^ PYI045 -26 | +26 | 27 | class IteratorReturn: | @@ -48,7 +47,7 @@ PYI045.pyi:46:28: PYI045 `__aiter__` methods should return an `AsyncIterator`, n 45 | class TypingAsyncIterableTReturn: 46 | def __aiter__(self) -> typing.AsyncIterable[int]: ... # Error: PYI045 | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI045 -47 | +47 | 48 | class TypingAsyncIterableReturn: | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI047_PYI047.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI047_PYI047.py.snap index 9e0fb19eeab92..3fda1b217df84 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI047_PYI047.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI047_PYI047.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI047.py:6:1: PYI047 Private TypeAlias `_UnusedPrivateTypeAlias` is never used | @@ -14,14 +13,14 @@ PYI047.py:7:1: PYI047 Private TypeAlias `_T` is never used 6 | _UnusedPrivateTypeAlias: TypeAlias = int | None 7 | _T: typing.TypeAlias = str | ^^ PYI047 -8 | +8 | 9 | # OK | PYI047.py:24:6: PYI047 Private TypeAlias `_UnusedPEP695` is never used | 22 | def func2(arg: _PrivateTypeAlias) -> None: ... -23 | +23 | 24 | type _UnusedPEP695 = int | ^^^^^^^^^^^^^ PYI047 25 | type _UnusedGeneric695[T] = list[T] @@ -32,6 +31,6 @@ PYI047.py:25:6: PYI047 Private TypeAlias `_UnusedGeneric695` is never used 24 | type _UnusedPEP695 = int 25 | type _UnusedGeneric695[T] = list[T] | ^^^^^^^^^^^^^^^^^ PYI047 -26 | +26 | 27 | type _UsedPEP695 = str | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI047_PYI047.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI047_PYI047.pyi.snap index 7d883e58e4992..a27c276530049 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI047_PYI047.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI047_PYI047.pyi.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI047.pyi:6:1: PYI047 Private TypeAlias `_UnusedPrivateTypeAlias` is never used | @@ -14,14 +13,14 @@ PYI047.pyi:7:1: PYI047 Private TypeAlias `_T` is never used 6 | _UnusedPrivateTypeAlias: TypeAlias = int | None 7 | _T: typing.TypeAlias = str | ^^ PYI047 -8 | +8 | 9 | # OK | PYI047.pyi:24:6: PYI047 Private TypeAlias `_UnusedPEP695` is never used | 22 | def func2(arg: _PrivateTypeAlias) -> None: ... -23 | +23 | 24 | type _UnusedPEP695 = int | ^^^^^^^^^^^^^ PYI047 25 | type _UnusedGeneric695[T] = list[T] @@ -32,6 +31,6 @@ PYI047.pyi:25:6: PYI047 Private TypeAlias `_UnusedGeneric695` is never used 24 | type _UnusedPEP695 = int 25 | type _UnusedGeneric695[T] = list[T] | ^^^^^^^^^^^^^^^^^ PYI047 -26 | +26 | 27 | type _UsedPEP695 = str | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI048_PYI048.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI048_PYI048.pyi.snap index 185bceeff070b..ffd683822afdf 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI048_PYI048.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI048_PYI048.pyi.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI048.pyi:8:5: PYI048 Function body must contain exactly one statement | 6 | """oof""" # OK - 7 | + 7 | 8 | def oof(): # ERROR PYI048 | ^^^ PYI048 9 | """oof""" @@ -15,7 +14,7 @@ PYI048.pyi:8:5: PYI048 Function body must contain exactly one statement PYI048.pyi:12:5: PYI048 Function body must contain exactly one statement | 10 | print("foo") -11 | +11 | 12 | def foo(): # ERROR PYI048 | ^^^ PYI048 13 | """foo""" @@ -25,7 +24,7 @@ PYI048.pyi:12:5: PYI048 Function body must contain exactly one statement PYI048.pyi:17:5: PYI048 Function body must contain exactly one statement | 15 | print("foo") -16 | +16 | 17 | def buzz(): # ERROR PYI048 | ^^^^ PYI048 18 | print("fizz") diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI049_PYI049.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI049_PYI049.pyi.snap index 4164e08658ccd..68cfc0c50ff83 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI049_PYI049.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI049_PYI049.pyi.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI049.pyi:6:7: PYI049 Private TypedDict `_UnusedTypedDict` is never used | @@ -19,7 +18,7 @@ PYI049.pyi:10:7: PYI049 Private TypedDict `_UnusedTypedDict2` is never used PYI049.pyi:34:1: PYI049 Private TypedDict `_UnusedTypedDict3` is never used | 32 | bar: list[int] -33 | +33 | 34 | _UnusedTypedDict3 = TypedDict("_UnusedTypedDict3", {"foo": int}) | ^^^^^^^^^^^^^^^^^ PYI049 35 | _UsedTypedDict3 = TypedDict("_UsedTypedDict3", {"bar": bytes}) diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI051_PYI051.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI051_PYI051.py.snap index db8a1c52f7ae6..84850e38e7fe5 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI051_PYI051.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI051_PYI051.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI051.py:4:18: PYI051 `Literal["foo"]` is redundant in a union with `str` | 2 | from typing import Literal, TypeAlias, Union -3 | +3 | 4 | A: str | Literal["foo"] | ^^^^^ PYI051 5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] @@ -95,26 +94,26 @@ PYI051.py:10:69: PYI051 `Literal["foo"]` is redundant in a union with `str` 9 | F: TypeAlias = typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] 10 | G: typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] | ^^^^^ PYI051 -11 | +11 | 12 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... | PYI051.py:12:31: PYI051 `Literal[1J]` is redundant in a union with `complex` | 10 | G: typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] -11 | +11 | 12 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... | ^^ PYI051 -13 | +13 | 14 | # OK | PYI051.py:12:53: PYI051 `Literal[3.14]` is redundant in a union with `float` | 10 | G: typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] -11 | +11 | 12 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... | ^^^^ PYI051 -13 | +13 | 14 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI051_PYI051.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI051_PYI051.pyi.snap index 8ddcd4893a115..cf1f213ca1f40 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI051_PYI051.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI051_PYI051.pyi.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI051.pyi:4:18: PYI051 `Literal["foo"]` is redundant in a union with `str` | 2 | from typing import Literal, TypeAlias, Union -3 | +3 | 4 | A: str | Literal["foo"] | ^^^^^ PYI051 5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] @@ -95,26 +94,26 @@ PYI051.pyi:10:69: PYI051 `Literal["foo"]` is redundant in a union with `str` 9 | F: TypeAlias = typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] 10 | G: typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] | ^^^^^ PYI051 -11 | +11 | 12 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... | PYI051.pyi:12:31: PYI051 `Literal[1J]` is redundant in a union with `complex` | 10 | G: typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] -11 | +11 | 12 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... | ^^ PYI051 -13 | +13 | 14 | # OK | PYI051.pyi:12:53: PYI051 `Literal[3.14]` is redundant in a union with `float` | 10 | G: typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] -11 | +11 | 12 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... | ^^^^ PYI051 -13 | +13 | 14 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI053_PYI053.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI053_PYI053.pyi.snap index de9bc7be61b72..c6cb6da87907d 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI053_PYI053.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI053_PYI053.pyi.snap @@ -66,10 +66,10 @@ PYI053.pyi:25:16: PYI053 [*] String and bytes literals longer than 50 characters PYI053.pyi:30:12: PYI053 [*] String and bytes literals longer than 50 characters are not permitted | 28 | foo: str = "50 character stringggggggggggggggggggggggggggggggg" # OK -29 | +29 | 30 | bar: str = "51 character stringgggggggggggggggggggggggggggggggg" # Error: PYI053 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 -31 | +31 | 32 | baz: bytes = b"50 character byte stringgggggggggggggggggggggggggg" # OK | = help: Replace with `...` @@ -87,10 +87,10 @@ PYI053.pyi:30:12: PYI053 [*] String and bytes literals longer than 50 characters PYI053.pyi:34:14: PYI053 [*] String and bytes literals longer than 50 characters are not permitted | 32 | baz: bytes = b"50 character byte stringgggggggggggggggggggggggggg" # OK -33 | +33 | 34 | qux: bytes = b"51 character byte stringggggggggggggggggggggggggggg\xff" # Error: PYI053 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 -35 | +35 | 36 | ffoo: str = f"50 character stringggggggggggggggggggggggggggggggg" # OK | = help: Replace with `...` @@ -108,10 +108,10 @@ PYI053.pyi:34:14: PYI053 [*] String and bytes literals longer than 50 characters PYI053.pyi:38:13: PYI053 [*] String and bytes literals longer than 50 characters are not permitted | 36 | ffoo: str = f"50 character stringggggggggggggggggggggggggggggggg" # OK -37 | +37 | 38 | fbar: str = f"51 character stringgggggggggggggggggggggggggggggggg" # Error: PYI053 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 -39 | +39 | 40 | class Demo: | = help: Replace with `...` @@ -149,10 +149,10 @@ PYI053.pyi:64:5: PYI053 [*] String and bytes literals longer than 50 characters PYI053.pyi:68:13: PYI053 [*] String and bytes literals longer than 50 characters are not permitted | 66 | def not_a_deprecated_function() -> None: ... -67 | +67 | 68 | fbaz: str = f"51 character {foo} stringgggggggggggggggggggggggggg" # Error: PYI053 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 -69 | +69 | 70 | from typing import TypeAlias, Literal, Annotated | = help: Replace with `...` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI054_PYI054.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI054_PYI054.pyi.snap index dc5e48b97a8a8..ec99151e033f3 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI054_PYI054.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI054_PYI054.pyi.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI054.pyi:2:16: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted | @@ -26,7 +25,7 @@ PYI054.pyi:4:17: PYI054 [*] Numeric literals with a string representation longer 3 | field03: int = -0xFFFFFFFF 4 | field04: int = -0xFFFFFFFFF # Error: PYI054 | ^^^^^^^^^^^ PYI054 -5 | +5 | 6 | field05: int = 1234567890 | = help: Replace with `...` @@ -68,7 +67,7 @@ PYI054.pyi:10:17: PYI054 [*] Numeric literals with a string representation longe 9 | field08: int = -1234567801 10 | field09: int = -234_567_890 # Error: PYI054 | ^^^^^^^^^^^ PYI054 -11 | +11 | 12 | field10: float = 123.456789 | = help: Replace with `...` @@ -109,7 +108,7 @@ PYI054.pyi:15:19: PYI054 [*] Numeric literals with a string representation longe 14 | field12: float = -123.456789 15 | field13: float = -123.567_890 # Error: PYI054 | ^^^^^^^^^^^ PYI054 -16 | +16 | 17 | field14: complex = 1e1234567j | = help: Replace with `...` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.pyi.snap index 33dd7ff67dc76..30515dd2290f5 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.pyi.snap @@ -4,7 +4,7 @@ source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs PYI055.pyi:4:4: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[int | str | complex]`. | 2 | from typing import Union -3 | +3 | 4 | s: builtins.type[int] | builtins.type[str] | builtins.type[complex] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 5 | t: type[int] | type[str] | type[float] @@ -152,7 +152,7 @@ PYI055.pyi:11:4: PYI055 [*] Multiple `type` members in a union. Combine them int 10 | y: Union[Union[Union[type[Union[float, int]], type[complex]]]] 11 | z: Union[type[complex], Union[Union[type[Union[float, int]]]]] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 -12 | +12 | 13 | def func(arg: type[int] | str | type[float]) -> None: ... | = help: Combine multiple `type` members @@ -170,10 +170,10 @@ PYI055.pyi:11:4: PYI055 [*] Multiple `type` members in a union. Combine them int PYI055.pyi:13:15: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[int | float]`. | 11 | z: Union[type[complex], Union[Union[type[Union[float, int]]]]] -12 | +12 | 13 | def func(arg: type[int] | str | type[float]) -> None: ... | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 -14 | +14 | 15 | # OK | = help: Combine multiple `type` members @@ -193,7 +193,7 @@ PYI055.pyi:23:7: PYI055 [*] Multiple `type` members in a union. Combine them int 22 | # PYI055 23 | item: type[requests_mock.Mocker] | type[httpretty] = requests_mock.Mocker | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 -24 | +24 | 25 | def func(): | = help: Combine multiple `type` members diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI056_PYI056.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI056_PYI056.py.snap index 1263e378908ca..c8d9583e3de2a 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI056_PYI056.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI056_PYI056.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI056.py:4:1: PYI056 Calling `.append()` on `__all__` may not be supported by all type checkers (use `+=` instead) | @@ -26,6 +25,6 @@ PYI056.py:6:1: PYI056 Calling `.remove()` on `__all__` may not be supported by a 5 | __all__.extend(["E", "Foo"]) 6 | __all__.remove("A") | ^^^^^^^^^^^^^^ PYI056 -7 | +7 | 8 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI056_PYI056.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI056_PYI056.pyi.snap index 5ce21b2983235..7e7f78519ec6b 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI056_PYI056.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI056_PYI056.pyi.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI056.pyi:4:1: PYI056 Calling `.append()` on `__all__` may not be supported by all type checkers (use `+=` instead) | @@ -26,6 +25,6 @@ PYI056.pyi:6:1: PYI056 Calling `.remove()` on `__all__` may not be supported by 5 | __all__.extend(["E", "Foo"]) 6 | __all__.remove("A") | ^^^^^^^^^^^^^^ PYI056 -7 | +7 | 8 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI057_PYI057.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI057_PYI057.py.snap index d7db1d959ce5a..efdd939335c25 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI057_PYI057.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI057_PYI057.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI057.py:4:20: PYI057 Do not use `typing.ByteString`, which has unclear semantics and is deprecated | @@ -24,7 +23,7 @@ PYI057.py:5:29: PYI057 Do not use `collections.abc.ByteString`, which has unclea PYI057.py:8:4: PYI057 Do not use `typing.ByteString`, which has unclear semantics and is deprecated | 6 | from foo import ByteString - 7 | + 7 | 8 | a: typing.ByteString | ^^^^^^^^^^^^^^^^^ PYI057 9 | b: collections.abc.ByteString diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI057_PYI057.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI057_PYI057.pyi.snap index 0be6f3fa5f39e..f1c72b4ba9111 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI057_PYI057.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI057_PYI057.pyi.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI057.pyi:4:20: PYI057 Do not use `typing.ByteString`, which has unclear semantics and is deprecated | @@ -24,7 +23,7 @@ PYI057.pyi:5:29: PYI057 Do not use `collections.abc.ByteString`, which has uncle PYI057.pyi:8:4: PYI057 Do not use `typing.ByteString`, which has unclear semantics and is deprecated | 6 | from foo import ByteString - 7 | + 7 | 8 | a: typing.ByteString | ^^^^^^^^^^^^^^^^^ PYI057 9 | b: collections.abc.ByteString diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI058_PYI058.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI058_PYI058.pyi.snap index 47c5de12a4303..915b6958e0474 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI058_PYI058.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI058_PYI058.pyi.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI058.pyi:5:13: PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods | 4 | class IteratorReturningSimpleGenerator1: 5 | def __iter__(self) -> Generator: ... # PYI058 (use `Iterator`) | ^^^^^^^^ PYI058 -6 | +6 | 7 | def scope(): | = help: Convert the return annotation of your `__iter__` method to `Iterator` @@ -29,7 +28,7 @@ PYI058.pyi:11:13: PYI058 [*] Use `Iterator` as the return value for simple `__it 10 | class IteratorReturningSimpleGenerator2: 11 | def __iter__(self) -> typing.Generator: ... # PYI058 (use `Iterator`) | ^^^^^^^^ PYI058 -12 | +12 | 13 | def scope(): | = help: Convert the return annotation of your `__iter__` method to `Iterator` @@ -49,7 +48,7 @@ PYI058.pyi:17:13: PYI058 [*] Use `Iterator` as the return value for simple `__it 16 | class IteratorReturningSimpleGenerator3: 17 | def __iter__(self) -> collections.abc.Generator: ... # PYI058 (use `Iterator`) | ^^^^^^^^ PYI058 -18 | +18 | 19 | def scope(): | = help: Convert the return annotation of your `__iter__` method to `Iterator` @@ -69,7 +68,7 @@ PYI058.pyi:24:13: PYI058 [*] Use `Iterator` as the return value for simple `__it 23 | class IteratorReturningSimpleGenerator4: 24 | def __iter__(self, /) -> collections.abc.Generator[str, Any, None]: ... # PYI058 (use `Iterator`) | ^^^^^^^^ PYI058 -25 | +25 | 26 | def scope(): | = help: Convert the return annotation of your `__iter__` method to `Iterator` @@ -89,7 +88,7 @@ PYI058.pyi:31:13: PYI058 [*] Use `Iterator` as the return value for simple `__it 30 | class IteratorReturningSimpleGenerator5: 31 | def __iter__(self, /) -> collections.abc.Generator[str, None, typing.Any]: ... # PYI058 (use `Iterator`) | ^^^^^^^^ PYI058 -32 | +32 | 33 | def scope(): | = help: Convert the return annotation of your `__iter__` method to `Iterator` @@ -109,7 +108,7 @@ PYI058.pyi:37:13: PYI058 [*] Use `Iterator` as the return value for simple `__it 36 | class IteratorReturningSimpleGenerator6: 37 | def __iter__(self, /) -> Generator[str, None, None]: ... # PYI058 (use `Iterator`) | ^^^^^^^^ PYI058 -38 | +38 | 39 | def scope(): | = help: Convert the return annotation of your `__iter__` method to `Iterator` @@ -134,7 +133,7 @@ PYI058.pyi:43:13: PYI058 [*] Use `AsyncIterator` as the return value for simple 42 | class AsyncIteratorReturningSimpleAsyncGenerator1: 43 | def __aiter__(self,) -> typing_extensions.AsyncGenerator: ... # PYI058 (Use `AsyncIterator`) | ^^^^^^^^^ PYI058 -44 | +44 | 45 | def scope(): | = help: Convert the return annotation of your `__aiter__` method to `AsyncIterator` @@ -173,7 +172,7 @@ PYI058.pyi:56:13: PYI058 [*] Use `AsyncIterator` as the return value for simple 55 | class AsyncIteratorReturningSimpleAsyncGenerator3: 56 | def __aiter__(self, /) -> collections.abc.AsyncGenerator[str, None]: ... # PYI058 (Use `AsyncIterator`) | ^^^^^^^^^ PYI058 -57 | +57 | 58 | def scope(): | = help: Convert the return annotation of your `__aiter__` method to `AsyncIterator` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.py.snap index b4095f293aa59..bc91fb867cef4 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI059.py:8:17: PYI059 [*] `Generic[]` should always be the last base class | 6 | V = TypeVar('V') - 7 | + 7 | 8 | class LinkedList(Generic[T], Sized): # PYI059 | ^^^^^^^^^^^^^^^^^^^ PYI059 9 | def __init__(self) -> None: @@ -26,7 +25,7 @@ PYI059.py:8:17: PYI059 [*] `Generic[]` should always be the last base class PYI059.py:15:16: PYI059 [*] `Generic[]` should always be the last base class | 13 | self._items.append(item) -14 | +14 | 15 | class MyMapping( # PYI059 | ________________^ 16 | | t.Generic[K, V], diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.pyi.snap index 0f0a1bb9d194f..275dd20dbaa08 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.pyi.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI059.pyi:8:17: PYI059 [*] `Generic[]` should always be the last base class | 6 | V = TypeVar('V') - 7 | + 7 | 8 | class LinkedList(Generic[T], Sized): # PYI059 | ^^^^^^^^^^^^^^^^^^^ PYI059 9 | def __init__(self) -> None: ... @@ -26,7 +25,7 @@ PYI059.pyi:8:17: PYI059 [*] `Generic[]` should always be the last base class PYI059.pyi:12:16: PYI059 [*] `Generic[]` should always be the last base class | 10 | def push(self, item: T) -> None: ... -11 | +11 | 12 | class MyMapping( # PYI059 | ________________^ 13 | | t.Generic[K, V], diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI061_PYI061.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI061_PYI061.py.snap index 06bec134febe7..558d4ee7397cb 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI061_PYI061.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI061_PYI061.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI061.py:4:25: PYI061 [*] `Literal[None]` can be replaced with `None` | @@ -208,7 +207,7 @@ PYI061.py:53:15: PYI061 [*] `Literal[None, ...]` can be replaced with `Literal[. 52 | Literal[None] # Y061 None inside "Literal[]" expression. Replace with "None" 53 | Literal[True, None] # Y061 None inside "Literal[]" expression. Replace with "Literal[True] | None" | ^^^^ PYI061 -54 | +54 | 55 | ### | = help: Replace with `Literal[...] | None` @@ -269,7 +268,7 @@ PYI061.py:63:12: PYI061 [*] `Literal[None, ...]` can be replaced with `Literal[. 62 | Literal[None, None] # Y061 None inside "Literal[]" expression. Replace with "None" 63 | Literal[1, None, "foo", None] # Y061 None inside "Literal[]" expression. Replace with "Literal[1, 'foo'] | None" | ^^^^ PYI061 -64 | +64 | 65 | # ... but if Y061 and Y062 both apply | = help: Replace with `Literal[...] | None` @@ -290,7 +289,7 @@ PYI061.py:63:25: PYI061 [*] `Literal[None, ...]` can be replaced with `Literal[. 62 | Literal[None, None] # Y061 None inside "Literal[]" expression. Replace with "None" 63 | Literal[1, None, "foo", None] # Y061 None inside "Literal[]" expression. Replace with "Literal[1, 'foo'] | None" | ^^^^ PYI061 -64 | +64 | 65 | # ... but if Y061 and Y062 both apply | = help: Replace with `Literal[...] | None` @@ -369,7 +368,7 @@ PYI061.py:74:18: PYI061 [*] `Literal[None]` can be replaced with `None` 73 | y: None | Literal[None] 74 | z: Union[Literal[None], None] | ^^^^ PYI061 -75 | +75 | 76 | a: int | Literal[None] | None | = help: Replace with `None` @@ -387,7 +386,7 @@ PYI061.py:74:18: PYI061 [*] `Literal[None]` can be replaced with `None` PYI061.py:76:18: PYI061 `Literal[None]` can be replaced with `None` | 74 | z: Union[Literal[None], None] -75 | +75 | 76 | a: int | Literal[None] | None | ^^^^ PYI061 77 | b: None | Literal[None] | None diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI061_PYI061.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI061_PYI061.pyi.snap index 1352d24f3935b..e1bc23eca4a0c 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI061_PYI061.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI061_PYI061.pyi.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI061.pyi:4:25: PYI061 [*] `Literal[None]` can be replaced with `None` | @@ -238,7 +237,7 @@ PYI061.pyi:49:18: PYI061 [*] `Literal[None]` can be replaced with `None` 48 | y: None | Literal[None] 49 | z: Union[Literal[None], None] | ^^^^ PYI061 -50 | +50 | 51 | a: int | Literal[None] | None | = help: Replace with `None` @@ -256,7 +255,7 @@ PYI061.pyi:49:18: PYI061 [*] `Literal[None]` can be replaced with `None` PYI061.pyi:51:18: PYI061 `Literal[None]` can be replaced with `None` | 49 | z: Union[Literal[None], None] -50 | +50 | 51 | a: int | Literal[None] | None | ^^^^ PYI061 52 | b: None | Literal[None] | None diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI062_PYI062.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI062_PYI062.py.snap index a2f290e969b07..6af025078bddf 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI062_PYI062.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI062_PYI062.py.snap @@ -4,10 +4,10 @@ source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs PYI062.py:5:25: PYI062 [*] Duplicate literal member `True` | 3 | import typing_extensions -4 | +4 | 5 | x: Literal[True, False, True, False] # PYI062 twice here | ^^^^ PYI062 -6 | +6 | 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1 | = help: Remove duplicates @@ -25,10 +25,10 @@ PYI062.py:5:25: PYI062 [*] Duplicate literal member `True` PYI062.py:5:31: PYI062 [*] Duplicate literal member `False` | 3 | import typing_extensions -4 | +4 | 5 | x: Literal[True, False, True, False] # PYI062 twice here | ^^^^^ PYI062 -6 | +6 | 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1 | = help: Remove duplicates @@ -46,10 +46,10 @@ PYI062.py:5:31: PYI062 [*] Duplicate literal member `False` PYI062.py:7:45: PYI062 [*] Duplicate literal member `1` | 5 | x: Literal[True, False, True, False] # PYI062 twice here -6 | +6 | 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1 | ^ PYI062 -8 | +8 | 9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal | = help: Remove duplicates @@ -67,10 +67,10 @@ PYI062.py:7:45: PYI062 [*] Duplicate literal member `1` PYI062.py:9:33: PYI062 [*] Duplicate literal member `{1, 3, 5}` | 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1 - 8 | + 8 | 9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal | ^^^^^^^ PYI062 -10 | +10 | 11 | Literal[1, Literal[1]] # once | = help: Remove duplicates @@ -88,7 +88,7 @@ PYI062.py:9:33: PYI062 [*] Duplicate literal member `{1, 3, 5}` PYI062.py:11:20: PYI062 [*] Duplicate literal member `1` | 9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal -10 | +10 | 11 | Literal[1, Literal[1]] # once | ^ PYI062 12 | Literal[1, 2, Literal[1, 2]] # twice @@ -303,7 +303,7 @@ PYI062.py:25:46: PYI062 [*] Duplicate literal member `True` 24 | # Ensure issue is only raised once, even on nested literals 25 | MyType = Literal["foo", Literal[True, False, True], "bar"] # PYI062 | ^^^^ PYI062 -26 | +26 | 27 | n: Literal["No", "duplicates", "here", 1, "1"] | = help: Remove duplicates diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI062_PYI062.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI062_PYI062.pyi.snap index f03c08bc343ce..60d45bc3c7d79 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI062_PYI062.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI062_PYI062.pyi.snap @@ -4,10 +4,10 @@ source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs PYI062.pyi:5:25: PYI062 [*] Duplicate literal member `True` | 3 | import typing_extensions -4 | +4 | 5 | x: Literal[True, False, True, False] # PYI062 twice here | ^^^^ PYI062 -6 | +6 | 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1 | = help: Remove duplicates @@ -25,10 +25,10 @@ PYI062.pyi:5:25: PYI062 [*] Duplicate literal member `True` PYI062.pyi:5:31: PYI062 [*] Duplicate literal member `False` | 3 | import typing_extensions -4 | +4 | 5 | x: Literal[True, False, True, False] # PYI062 twice here | ^^^^^ PYI062 -6 | +6 | 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1 | = help: Remove duplicates @@ -46,10 +46,10 @@ PYI062.pyi:5:31: PYI062 [*] Duplicate literal member `False` PYI062.pyi:7:45: PYI062 [*] Duplicate literal member `1` | 5 | x: Literal[True, False, True, False] # PYI062 twice here -6 | +6 | 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1 | ^ PYI062 -8 | +8 | 9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal | = help: Remove duplicates @@ -67,10 +67,10 @@ PYI062.pyi:7:45: PYI062 [*] Duplicate literal member `1` PYI062.pyi:9:33: PYI062 [*] Duplicate literal member `{1, 3, 5}` | 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1 - 8 | + 8 | 9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal | ^^^^^^^ PYI062 -10 | +10 | 11 | Literal[1, Literal[1]] # once | = help: Remove duplicates @@ -88,7 +88,7 @@ PYI062.pyi:9:33: PYI062 [*] Duplicate literal member `{1, 3, 5}` PYI062.pyi:11:20: PYI062 [*] Duplicate literal member `1` | 9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal -10 | +10 | 11 | Literal[1, Literal[1]] # once | ^ PYI062 12 | Literal[1, 2, Literal[1, 2]] # twice @@ -303,7 +303,7 @@ PYI062.pyi:25:46: PYI062 [*] Duplicate literal member `True` 24 | # Ensure issue is only raised once, even on nested literals 25 | MyType = Literal["foo", Literal[True, False, True], "bar"] # PYI062 | ^^^^ PYI062 -26 | +26 | 27 | n: Literal["No", "duplicates", "here", 1, "1"] | = help: Remove duplicates diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI063_PYI063.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI063_PYI063.py.snap index 04c88e35cf9b4..044005bebb802 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI063_PYI063.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI063_PYI063.py.snap @@ -4,7 +4,7 @@ source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs PYI063.py:6:9: PYI063 Use PEP 570 syntax for positional-only parameters | 4 | from typing import Self -5 | +5 | 6 | def bad(__x: int) -> None: ... # PYI063 | ^^^ PYI063 7 | def also_bad(__x: int, __y: str) -> None: ... # PYI063 @@ -27,7 +27,7 @@ PYI063.py:8:15: PYI063 Use PEP 570 syntax for positional-only parameters 7 | def also_bad(__x: int, __y: str) -> None: ... # PYI063 8 | def still_bad(__x_: int) -> None: ... # PYI063 | ^^^^ PYI063 - 9 | + 9 | 10 | def no_args() -> None: ... | = help: Add `/` to function signature @@ -82,7 +82,7 @@ PYI063.py:30:23: PYI063 Use PEP 570 syntax for positional-only parameters 29 | @classmethod 30 | def not_good(cls, __foo: int) -> None: ... # PYI063 | ^^^^^ PYI063 -31 | +31 | 32 | # The first non-self argument isn't positional-only, so logically the second can't be either: | = help: Add `/` to function signature @@ -93,7 +93,7 @@ PYI063.py:52:23: PYI063 Use PEP 570 syntax for positional-only parameters 51 | @classmethod 52 | def __new__(mcls, __name: str, __bases: tuple[type, ...], __namespace: dict, **kwds) -> Self: ... # PYI063 | ^^^^^^ PYI063 -53 | +53 | 54 | class Metaclass2(type): | = help: Add `/` to function signature @@ -104,7 +104,7 @@ PYI063.py:56:26: PYI063 Use PEP 570 syntax for positional-only parameters 55 | @classmethod 56 | def __new__(metacls, __name: str, __bases: tuple[type, ...], __namespace: dict, **kwds) -> Self: ... # PYI063 | ^^^^^^ PYI063 -57 | +57 | 58 | class GoodMetaclass(type): | = help: Add `/` to function signature diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI063_PYI063.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI063_PYI063.pyi.snap index f7d4f4de5448a..093baf963ab26 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI063_PYI063.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI063_PYI063.pyi.snap @@ -4,7 +4,7 @@ source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs PYI063.pyi:6:9: PYI063 Use PEP 570 syntax for positional-only parameters | 4 | from typing import Self -5 | +5 | 6 | def bad(__x: int) -> None: ... # PYI063 | ^^^ PYI063 7 | def also_bad(__x: int, __y: str) -> None: ... # PYI063 @@ -27,7 +27,7 @@ PYI063.pyi:8:15: PYI063 Use PEP 570 syntax for positional-only parameters 7 | def also_bad(__x: int, __y: str) -> None: ... # PYI063 8 | def still_bad(__x_: int) -> None: ... # PYI063 | ^^^^ PYI063 - 9 | + 9 | 10 | def no_args() -> None: ... | = help: Add `/` to function signature @@ -82,7 +82,7 @@ PYI063.pyi:30:23: PYI063 Use PEP 570 syntax for positional-only parameters 29 | @classmethod 30 | def not_good(cls, __foo: int) -> None: ... # PYI063 | ^^^^^ PYI063 -31 | +31 | 32 | # The first non-self argument isn't positional-only, so logically the second can't be either: | = help: Add `/` to function signature @@ -93,7 +93,7 @@ PYI063.pyi:52:23: PYI063 Use PEP 570 syntax for positional-only parameters 51 | @classmethod 52 | def __new__(mcls, __name: str, __bases: tuple[type, ...], __namespace: dict, **kwds) -> Self: ... # PYI063 | ^^^^^^ PYI063 -53 | +53 | 54 | class Metaclass2(type): | = help: Add `/` to function signature @@ -104,7 +104,7 @@ PYI063.pyi:56:26: PYI063 Use PEP 570 syntax for positional-only parameters 55 | @classmethod 56 | def __new__(metacls, __name: str, __bases: tuple[type, ...], __namespace: dict, **kwds) -> Self: ... # PYI063 | ^^^^^^ PYI063 -57 | +57 | 58 | class GoodMetaclass(type): | = help: Add `/` to function signature diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.py.snap index 6024f775553aa..f212abc18bb62 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI064.py:3:1: PYI064 [*] `Final[Literal[True]]` can be replaced with a bare `Final` | 1 | from typing import Final, Literal -2 | +2 | 3 | x: Final[Literal[True]] = True # PYI064 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI064 4 | y: Final[Literal[None]] = None # PYI064 @@ -50,7 +49,7 @@ PYI064.py:5:1: PYI064 [*] `Final[Literal[...]]` can be replaced with a bare `Fin 6 | | "this is a really long literal, that won't be rendered in the issue text" 7 | | ]] = "this is a really long literal, that won't be rendered in the issue text" | |______________________________________________________________________________^ PYI064 -8 | +8 | 9 | # This should be fixable, and marked as safe | = help: Replace with `Final` @@ -72,7 +71,7 @@ PYI064.py:10:1: PYI064 [*] `Final[Literal[123]]` can be replaced with a bare `Fi 9 | # This should be fixable, and marked as safe 10 | w1: Final[Literal[123]] # PYI064 | ^^^^^^^^^^^^^^^^^^^^^^^ PYI064 -11 | +11 | 12 | # This should not be fixable | = help: Replace with `Final` @@ -92,7 +91,7 @@ PYI064.py:13:1: PYI064 `Final[Literal[123]]` can be replaced with a bare `Final` 12 | # This should not be fixable 13 | w2: Final[Literal[123]] = "random value" # PYI064 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI064 -14 | +14 | 15 | n1: Final[Literal[True, False]] = True # No issue here | = help: Replace with `Final` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.pyi.snap index 6bd5bb04b4594..b02cfb5cc89b9 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.pyi.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI064.pyi:3:1: PYI064 [*] `Final[Literal[True]]` can be replaced with a bare `Final` | 1 | from typing import Final, Literal -2 | +2 | 3 | x: Final[Literal[True]] # PYI064 | ^^^^^^^^^^^^^^^^^^^^^^^ PYI064 4 | y: Final[Literal[None]] = None # PYI064 @@ -47,7 +46,7 @@ PYI064.pyi:5:1: PYI064 [*] `Final[Literal[...]]` can be replaced with a bare `Fi 4 | y: Final[Literal[None]] = None # PYI064 5 | z: Final[Literal["this is a really long literal, that won't be rendered in the issue text"]] # PYI064 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI064 -6 | +6 | 7 | # This should be fixable, and marked as safe | = help: Replace with `Final` @@ -67,7 +66,7 @@ PYI064.pyi:8:1: PYI064 [*] `Final[Literal[123]]` can be replaced with a bare `Fi 7 | # This should be fixable, and marked as safe 8 | w1: Final[Literal[123]] # PYI064 | ^^^^^^^^^^^^^^^^^^^^^^^ PYI064 - 9 | + 9 | 10 | # This should not be fixable | = help: Replace with `Final` @@ -87,7 +86,7 @@ PYI064.pyi:11:1: PYI064 `Final[Literal[123]]` can be replaced with a bare `Final 10 | # This should not be fixable 11 | w2: Final[Literal[123]] = "random value" # PYI064 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI064 -12 | +12 | 13 | n1: Final[Literal[True, False]] # No issue here | = help: Replace with `Final` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__custom_classmethod_rules_preview.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__custom_classmethod_rules_preview.snap index 57ed22c125195..9ed684d0c3527 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__custom_classmethod_rules_preview.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__custom_classmethod_rules_preview.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI019.pyi:7:62: PYI019 Methods like `__new__` should return `Self` instead of a custom `TypeVar` | @@ -134,7 +133,7 @@ PYI019.pyi:61:48: PYI019 [*] Methods like `__new__` should return `Self` instead 60 | class PEP695Fix: 61 | def __new__[S: PEP695Fix](cls: type[S]) -> S: ... | ^ PYI019 -62 | +62 | 63 | def __init_subclass__[S](cls: type[S]) -> S: ... | = help: Replace with `Self` @@ -152,10 +151,10 @@ PYI019.pyi:61:48: PYI019 [*] Methods like `__new__` should return `Self` instead PYI019.pyi:63:47: PYI019 [*] Methods like `__init_subclass__` should return `Self` instead of a custom `TypeVar` | 61 | def __new__[S: PEP695Fix](cls: type[S]) -> S: ... -62 | +62 | 63 | def __init_subclass__[S](cls: type[S]) -> S: ... | ^ PYI019 -64 | +64 | 65 | def __neg__[S: PEP695Fix](self: S) -> S: ... | = help: Replace with `Self` @@ -173,10 +172,10 @@ PYI019.pyi:63:47: PYI019 [*] Methods like `__init_subclass__` should return `Sel PYI019.pyi:65:43: PYI019 [*] Methods like `__neg__` should return `Self` instead of a custom `TypeVar` | 63 | def __init_subclass__[S](cls: type[S]) -> S: ... -64 | +64 | 65 | def __neg__[S: PEP695Fix](self: S) -> S: ... | ^ PYI019 -66 | +66 | 67 | def __pos__[S](self: S) -> S: ... | = help: Replace with `Self` @@ -194,10 +193,10 @@ PYI019.pyi:65:43: PYI019 [*] Methods like `__neg__` should return `Self` instead PYI019.pyi:67:32: PYI019 [*] Methods like `__pos__` should return `Self` instead of a custom `TypeVar` | 65 | def __neg__[S: PEP695Fix](self: S) -> S: ... -66 | +66 | 67 | def __pos__[S](self: S) -> S: ... | ^ PYI019 -68 | +68 | 69 | def __add__[S: PEP695Fix](self: S, other: S) -> S: ... | = help: Replace with `Self` @@ -215,10 +214,10 @@ PYI019.pyi:67:32: PYI019 [*] Methods like `__pos__` should return `Self` instead PYI019.pyi:69:53: PYI019 [*] Methods like `__add__` should return `Self` instead of a custom `TypeVar` | 67 | def __pos__[S](self: S) -> S: ... -68 | +68 | 69 | def __add__[S: PEP695Fix](self: S, other: S) -> S: ... | ^ PYI019 -70 | +70 | 71 | def __sub__[S](self: S, other: S) -> S: ... | = help: Replace with `Self` @@ -236,10 +235,10 @@ PYI019.pyi:69:53: PYI019 [*] Methods like `__add__` should return `Self` instead PYI019.pyi:71:42: PYI019 [*] Methods like `__sub__` should return `Self` instead of a custom `TypeVar` | 69 | def __add__[S: PEP695Fix](self: S, other: S) -> S: ... -70 | +70 | 71 | def __sub__[S](self: S, other: S) -> S: ... | ^ PYI019 -72 | +72 | 73 | @classmethod | = help: Replace with `Self` @@ -259,7 +258,7 @@ PYI019.pyi:74:59: PYI019 [*] Methods like `class_method_bound` should return `Se 73 | @classmethod 74 | def class_method_bound[S: PEP695Fix](cls: type[S]) -> S: ... | ^ PYI019 -75 | +75 | 76 | @classmethod | = help: Replace with `Self` @@ -279,7 +278,7 @@ PYI019.pyi:77:50: PYI019 [*] Methods like `class_method_unbound` should return ` 76 | @classmethod 77 | def class_method_unbound[S](cls: type[S]) -> S: ... | ^ PYI019 -78 | +78 | 79 | def instance_method_bound[S: PEP695Fix](self: S) -> S: ... | = help: Replace with `Self` @@ -297,10 +296,10 @@ PYI019.pyi:77:50: PYI019 [*] Methods like `class_method_unbound` should return ` PYI019.pyi:79:57: PYI019 [*] Methods like `instance_method_bound` should return `Self` instead of a custom `TypeVar` | 77 | def class_method_unbound[S](cls: type[S]) -> S: ... -78 | +78 | 79 | def instance_method_bound[S: PEP695Fix](self: S) -> S: ... | ^ PYI019 -80 | +80 | 81 | def instance_method_unbound[S](self: S) -> S: ... | = help: Replace with `Self` @@ -318,10 +317,10 @@ PYI019.pyi:79:57: PYI019 [*] Methods like `instance_method_bound` should return PYI019.pyi:81:48: PYI019 [*] Methods like `instance_method_unbound` should return `Self` instead of a custom `TypeVar` | 79 | def instance_method_bound[S: PEP695Fix](self: S) -> S: ... -80 | +80 | 81 | def instance_method_unbound[S](self: S) -> S: ... | ^ PYI019 -82 | +82 | 83 | def instance_method_bound_with_another_parameter[S: PEP695Fix](self: S, other: S) -> S: ... | = help: Replace with `Self` @@ -339,10 +338,10 @@ PYI019.pyi:81:48: PYI019 [*] Methods like `instance_method_unbound` should retur PYI019.pyi:83:90: PYI019 [*] Methods like `instance_method_bound_with_another_parameter` should return `Self` instead of a custom `TypeVar` | 81 | def instance_method_unbound[S](self: S) -> S: ... -82 | +82 | 83 | def instance_method_bound_with_another_parameter[S: PEP695Fix](self: S, other: S) -> S: ... | ^ PYI019 -84 | +84 | 85 | def instance_method_unbound_with_another_parameter[S](self: S, other: S) -> S: ... | = help: Replace with `Self` @@ -360,10 +359,10 @@ PYI019.pyi:83:90: PYI019 [*] Methods like `instance_method_bound_with_another_pa PYI019.pyi:85:81: PYI019 [*] Methods like `instance_method_unbound_with_another_parameter` should return `Self` instead of a custom `TypeVar` | 83 | def instance_method_bound_with_another_parameter[S: PEP695Fix](self: S, other: S) -> S: ... -84 | +84 | 85 | def instance_method_unbound_with_another_parameter[S](self: S, other: S) -> S: ... | ^ PYI019 -86 | +86 | 87 | def multiple_type_vars[S, *Ts, T](self: S, other: S, /, *args: *Ts, a: T, b: list[T]) -> S: ... | = help: Replace with `Self` @@ -381,10 +380,10 @@ PYI019.pyi:85:81: PYI019 [*] Methods like `instance_method_unbound_with_another_ PYI019.pyi:87:94: PYI019 Methods like `multiple_type_vars` should return `Self` instead of a custom `TypeVar` | 85 | def instance_method_unbound_with_another_parameter[S](self: S, other: S) -> S: ... -86 | +86 | 87 | def multiple_type_vars[S, *Ts, T](self: S, other: S, /, *args: *Ts, a: T, b: list[T]) -> S: ... | ^ PYI019 -88 | +88 | 89 | def mixing_old_and_new_style_type_vars[T](self: _S695, a: T, b: T) -> _S695: ... | = help: Replace with `Self` @@ -401,7 +400,7 @@ PYI019.pyi:87:94: PYI019 Methods like `multiple_type_vars` should return `Self` PYI019.pyi:89:75: PYI019 Methods like `mixing_old_and_new_style_type_vars` should return `Self` instead of a custom `TypeVar` | 87 | def multiple_type_vars[S, *Ts, T](self: S, other: S, /, *args: *Ts, a: T, b: list[T]) -> S: ... -88 | +88 | 89 | def mixing_old_and_new_style_type_vars[T](self: _S695, a: T, b: T) -> _S695: ... | ^^^^^ PYI019 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__preview__PYI044_PYI044.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__preview__PYI044_PYI044.pyi.snap index fbeb56a996ddd..4ae21763be417 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__preview__PYI044_PYI044.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__preview__PYI044_PYI044.pyi.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI044.pyi:2:1: PYI044 [*] `from __future__ import annotations` has no effect in stub files, since type checkers automatically treat stubs as having those semantics | @@ -24,7 +23,7 @@ PYI044.pyi:3:1: PYI044 [*] `from __future__ import annotations` has no effect in 2 | from __future__ import annotations # PYI044. 3 | from __future__ import annotations, with_statement # PYI044. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI044 -4 | +4 | 5 | # Good imports. | = help: Remove `from __future__ import annotations` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI026_PYI026.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI026_PYI026.pyi.snap index 50f0d9a5fe766..17bb45aedd6bb 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI026_PYI026.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI026_PYI026.pyi.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI026.pyi:3:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `NewAny: TypeAlias = Any` | 1 | from typing import Literal, Any -2 | +2 | 3 | NewAny = Any | ^^^^^^ PYI026 4 | OptionalStr = typing.Optional[str] @@ -96,7 +95,7 @@ PYI026.pyi:7:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g 6 | IntOrStr = int | str 7 | AliasNone = None | ^^^^^^^^^ PYI026 -8 | +8 | 9 | NewAny: typing.TypeAlias = Any | = help: Add `TypeAlias` annotation @@ -120,7 +119,7 @@ PYI026.pyi:17:5: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e. 16 | class NotAnEnum: 17 | FLAG_THIS = None | ^^^^^^^^^ PYI026 -18 | +18 | 19 | # these are ok | = help: Add `TypeAlias` annotation diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_default.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_default.snap index 3a95ca7c64056..8bcf1ce60d196 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_default.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_default.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- PT001.py:14:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` | @@ -24,7 +23,7 @@ PT001.py:14:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` PT001.py:24:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` | 24 | / @pytest.fixture( -25 | | +25 | | 26 | | ) | |_^ PT001 27 | def parentheses_no_params_multiline(): @@ -66,7 +65,7 @@ PT001.py:39:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` PT001.py:49:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` | 49 | / @fixture( -50 | | +50 | | 51 | | ) | |_^ PT001 52 | def imported_from_parentheses_no_params_multiline(): @@ -108,7 +107,7 @@ PT001.py:64:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` PT001.py:74:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` | 74 | / @aliased( -75 | | +75 | | 76 | | ) | |_^ PT001 77 | def aliased_parentheses_no_params_multiline(): diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_and_PT007.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_and_PT007.snap index 8427630045402..53fcf3c33ab39 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_and_PT007.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_and_PT007.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- PT006_and_PT007.py:3:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` | 1 | import pytest -2 | +2 | 3 | @pytest.mark.parametrize(("param",), [[1], [2]]) | ^^^^^^^^^^ PT006 4 | def test_PT006_and_PT007_do_not_conflict(param): @@ -24,7 +23,7 @@ PT006_and_PT007.py:3:26: PT006 [*] Wrong type passed to first argument of `pytes PT006_and_PT007.py:3:39: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` | 1 | import pytest -2 | +2 | 3 | @pytest.mark.parametrize(("param",), [[1], [2]]) | ^^^ PT007 4 | def test_PT006_and_PT007_do_not_conflict(param): @@ -43,7 +42,7 @@ PT006_and_PT007.py:3:39: PT007 [*] Wrong values type in `pytest.mark.parametrize PT006_and_PT007.py:3:44: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` | 1 | import pytest -2 | +2 | 3 | @pytest.mark.parametrize(("param",), [[1], [2]]) | ^^^ PT007 4 | def test_PT006_and_PT007_do_not_conflict(param): diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_default.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_default.snap index fc83efbb15732..fa23a2d752c26 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_default.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_default.snap @@ -234,7 +234,7 @@ PT006.py:74:39: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa | 74 | parametrize = pytest.mark.parametrize(("param1,param2"), [(1, 2), (3, 4)]) | ^^^^^^^^^^^^^^^^^ PT006 -75 | +75 | 76 | @parametrize | = help: Use a `tuple` for the first argument diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_list.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_list.snap index de2c60ae0393c..8ccc8345e7b99 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_list.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_list.snap @@ -196,7 +196,7 @@ PT006.py:74:39: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa | 74 | parametrize = pytest.mark.parametrize(("param1,param2"), [(1, 2), (3, 4)]) | ^^^^^^^^^^^^^^^^^ PT006 -75 | +75 | 76 | @parametrize | = help: Use a `list` for the first argument diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT008.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT008.snap index 04372accb858d..7d366bf5c4896 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT008.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT008.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- PT008.py:35:1: PT008 Use `return_value=` instead of patching with `lambda` | 33 | # Error -34 | +34 | 35 | mocker.patch("module.name", lambda: None) | ^^^^^^^^^^^^ PT008 36 | module_mocker.patch("module.name", lambda: None) @@ -36,14 +35,14 @@ PT008.py:38:1: PT008 Use `return_value=` instead of patching with `lambda` 37 | mocker.patch.object(obj, "attr", lambda: None) 38 | module_mocker.patch.object(obj, "attr", lambda: None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PT008 -39 | +39 | 40 | mocker.patch("module.name", lambda x, y: None) | PT008.py:40:1: PT008 Use `return_value=` instead of patching with `lambda` | 38 | module_mocker.patch.object(obj, "attr", lambda: None) -39 | +39 | 40 | mocker.patch("module.name", lambda x, y: None) | ^^^^^^^^^^^^ PT008 41 | module_mocker.patch("module.name", lambda x, y: None) @@ -74,14 +73,14 @@ PT008.py:43:1: PT008 Use `return_value=` instead of patching with `lambda` 42 | mocker.patch.object(obj, "attr", lambda x, y: None) 43 | module_mocker.patch.object(obj, "attr", lambda x, y: None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PT008 -44 | +44 | 45 | mocker.patch("module.name", lambda *args, **kwargs: None) | PT008.py:45:1: PT008 Use `return_value=` instead of patching with `lambda` | 43 | module_mocker.patch.object(obj, "attr", lambda x, y: None) -44 | +44 | 45 | mocker.patch("module.name", lambda *args, **kwargs: None) | ^^^^^^^^^^^^ PT008 46 | module_mocker.patch("module.name", lambda *args, **kwargs: None) diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT009.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT009.snap index 3a26cdd240d0b..54aa27fa16c59 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT009.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT009.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- PT009.py:11:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` | @@ -179,7 +178,7 @@ PT009.py:25:16: PT009 Use a regular `assert` instead of unittest-style `assertEq 24 | ) 25 | return self.assertEqual(True, False) # Error, unfixable | ^^^^^^^^^^^^^^^^ PT009 -26 | +26 | 27 | def test_assert_false(self): | = help: Replace `assertEqual(...)` with `assert ...` @@ -189,7 +188,7 @@ PT009.py:28:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 27 | def test_assert_false(self): 28 | self.assertFalse(True) # Error | ^^^^^^^^^^^^^^^^ PT009 -29 | +29 | 30 | def test_assert_equal(self): | = help: Replace `assertFalse(...)` with `assert ...` @@ -209,7 +208,7 @@ PT009.py:31:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 30 | def test_assert_equal(self): 31 | self.assertEqual(1, 2) # Error | ^^^^^^^^^^^^^^^^ PT009 -32 | +32 | 33 | def test_assert_not_equal(self): | = help: Replace `assertEqual(...)` with `assert ...` @@ -229,7 +228,7 @@ PT009.py:34:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 33 | def test_assert_not_equal(self): 34 | self.assertNotEqual(1, 1) # Error | ^^^^^^^^^^^^^^^^^^^ PT009 -35 | +35 | 36 | def test_assert_greater(self): | = help: Replace `assertNotEqual(...)` with `assert ...` @@ -249,7 +248,7 @@ PT009.py:37:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 36 | def test_assert_greater(self): 37 | self.assertGreater(1, 2) # Error | ^^^^^^^^^^^^^^^^^^ PT009 -38 | +38 | 39 | def test_assert_greater_equal(self): | = help: Replace `assertGreater(...)` with `assert ...` @@ -269,7 +268,7 @@ PT009.py:40:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 39 | def test_assert_greater_equal(self): 40 | self.assertGreaterEqual(1, 2) # Error | ^^^^^^^^^^^^^^^^^^^^^^^ PT009 -41 | +41 | 42 | def test_assert_less(self): | = help: Replace `assertGreaterEqual(...)` with `assert ...` @@ -289,7 +288,7 @@ PT009.py:43:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 42 | def test_assert_less(self): 43 | self.assertLess(2, 1) # Error | ^^^^^^^^^^^^^^^ PT009 -44 | +44 | 45 | def test_assert_less_equal(self): | = help: Replace `assertLess(...)` with `assert ...` @@ -309,7 +308,7 @@ PT009.py:46:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 45 | def test_assert_less_equal(self): 46 | self.assertLessEqual(1, 2) # Error | ^^^^^^^^^^^^^^^^^^^^ PT009 -47 | +47 | 48 | def test_assert_in(self): | = help: Replace `assertLessEqual(...)` with `assert ...` @@ -329,7 +328,7 @@ PT009.py:49:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 48 | def test_assert_in(self): 49 | self.assertIn(1, [2, 3]) # Error | ^^^^^^^^^^^^^ PT009 -50 | +50 | 51 | def test_assert_not_in(self): | = help: Replace `assertIn(...)` with `assert ...` @@ -349,7 +348,7 @@ PT009.py:52:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 51 | def test_assert_not_in(self): 52 | self.assertNotIn(2, [2, 3]) # Error | ^^^^^^^^^^^^^^^^ PT009 -53 | +53 | 54 | def test_assert_is_none(self): | = help: Replace `assertNotIn(...)` with `assert ...` @@ -369,7 +368,7 @@ PT009.py:55:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 54 | def test_assert_is_none(self): 55 | self.assertIsNone(0) # Error | ^^^^^^^^^^^^^^^^^ PT009 -56 | +56 | 57 | def test_assert_is_not_none(self): | = help: Replace `assertIsNone(...)` with `assert ...` @@ -389,7 +388,7 @@ PT009.py:58:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 57 | def test_assert_is_not_none(self): 58 | self.assertIsNotNone(0) # Error | ^^^^^^^^^^^^^^^^^^^^ PT009 -59 | +59 | 60 | def test_assert_is(self): | = help: Replace `assertIsNotNone(...)` with `assert ...` @@ -409,7 +408,7 @@ PT009.py:61:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 60 | def test_assert_is(self): 61 | self.assertIs([], []) # Error | ^^^^^^^^^^^^^ PT009 -62 | +62 | 63 | def test_assert_is_not(self): | = help: Replace `assertIs(...)` with `assert ...` @@ -429,7 +428,7 @@ PT009.py:64:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 63 | def test_assert_is_not(self): 64 | self.assertIsNot(1, 1) # Error | ^^^^^^^^^^^^^^^^ PT009 -65 | +65 | 66 | def test_assert_is_instance(self): | = help: Replace `assertIsNot(...)` with `assert ...` @@ -449,7 +448,7 @@ PT009.py:67:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 66 | def test_assert_is_instance(self): 67 | self.assertIsInstance(1, str) # Error | ^^^^^^^^^^^^^^^^^^^^^ PT009 -68 | +68 | 69 | def test_assert_is_not_instance(self): | = help: Replace `assertIsInstance(...)` with `assert ...` @@ -469,7 +468,7 @@ PT009.py:70:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 69 | def test_assert_is_not_instance(self): 70 | self.assertNotIsInstance(1, int) # Error | ^^^^^^^^^^^^^^^^^^^^^^^^ PT009 -71 | +71 | 72 | def test_assert_regex(self): | = help: Replace `assertNotIsInstance(...)` with `assert ...` @@ -489,7 +488,7 @@ PT009.py:73:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 72 | def test_assert_regex(self): 73 | self.assertRegex("abc", r"def") # Error | ^^^^^^^^^^^^^^^^ PT009 -74 | +74 | 75 | def test_assert_not_regex(self): | = help: Replace `assertRegex(...)` with `assert ...` @@ -509,7 +508,7 @@ PT009.py:76:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 75 | def test_assert_not_regex(self): 76 | self.assertNotRegex("abc", r"abc") # Error | ^^^^^^^^^^^^^^^^^^^ PT009 -77 | +77 | 78 | def test_assert_regexp_matches(self): | = help: Replace `assertNotRegex(...)` with `assert ...` @@ -529,7 +528,7 @@ PT009.py:79:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 78 | def test_assert_regexp_matches(self): 79 | self.assertRegexpMatches("abc", r"def") # Error | ^^^^^^^^^^^^^^^^^^^^^^^^ PT009 -80 | +80 | 81 | def test_assert_not_regexp_matches(self): | = help: Replace `assertRegexpMatches(...)` with `assert ...` @@ -549,7 +548,7 @@ PT009.py:82:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 81 | def test_assert_not_regexp_matches(self): 82 | self.assertNotRegex("abc", r"abc") # Error | ^^^^^^^^^^^^^^^^^^^ PT009 -83 | +83 | 84 | def test_fail_if(self): | = help: Replace `assertNotRegex(...)` with `assert ...` @@ -569,7 +568,7 @@ PT009.py:85:9: PT009 [*] Use a regular `assert` instead of unittest-style `failI 84 | def test_fail_if(self): 85 | self.failIf("abc") # Error | ^^^^^^^^^^^ PT009 -86 | +86 | 87 | def test_fail_unless(self): | = help: Replace `failIf(...)` with `assert ...` @@ -589,7 +588,7 @@ PT009.py:88:9: PT009 [*] Use a regular `assert` instead of unittest-style `failU 87 | def test_fail_unless(self): 88 | self.failUnless("abc") # Error | ^^^^^^^^^^^^^^^ PT009 -89 | +89 | 90 | def test_fail_unless_equal(self): | = help: Replace `failUnless(...)` with `assert ...` @@ -609,7 +608,7 @@ PT009.py:91:9: PT009 [*] Use a regular `assert` instead of unittest-style `failU 90 | def test_fail_unless_equal(self): 91 | self.failUnlessEqual(1, 2) # Error | ^^^^^^^^^^^^^^^^^^^^ PT009 -92 | +92 | 93 | def test_fail_if_equal(self): | = help: Replace `failUnlessEqual(...)` with `assert ...` diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_default.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_default.snap index 6b57732fdcc9a..57b6b6f3933ce 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_default.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_default.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- PT011.py:18:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception | @@ -13,7 +12,7 @@ PT011.py:18:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` PT011.py:21:43: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception | 19 | raise ValueError("Can't divide 1 by 0") -20 | +20 | 21 | with pytest.raises(expected_exception=ValueError): | ^^^^^^^^^^ PT011 22 | raise ValueError("Can't divide 1 by 0") @@ -22,7 +21,7 @@ PT011.py:21:43: PT011 `pytest.raises(ValueError)` is too broad, set the `match` PT011.py:24:24: PT011 `pytest.raises(socket.error)` is too broad, set the `match` parameter or use a more specific exception | 22 | raise ValueError("Can't divide 1 by 0") -23 | +23 | 24 | with pytest.raises(socket.error): | ^^^^^^^^^^^^ PT011 25 | raise ValueError("Can't divide 1 by 0") @@ -39,7 +38,7 @@ PT011.py:35:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` PT011.py:38:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception | 36 | raise ValueError("Can't divide 1 by 0") -37 | +37 | 38 | with pytest.raises(ValueError, match=""): | ^^^^^^^^^^ PT011 39 | raise ValueError("Can't divide 1 by 0") @@ -48,7 +47,7 @@ PT011.py:38:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` PT011.py:41:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception | 39 | raise ValueError("Can't divide 1 by 0") -40 | +40 | 41 | with pytest.raises(ValueError, match=f""): | ^^^^^^^^^^ PT011 42 | raise ValueError("Can't divide 1 by 0") diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_extend_broad_exceptions.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_extend_broad_exceptions.snap index 1e03532e707d6..a256d353535d2 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_extend_broad_exceptions.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_extend_broad_exceptions.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- PT011.py:13:24: PT011 `pytest.raises(ZeroDivisionError)` is too broad, set the `match` parameter or use a more specific exception | @@ -21,7 +20,7 @@ PT011.py:18:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` PT011.py:21:43: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception | 19 | raise ValueError("Can't divide 1 by 0") -20 | +20 | 21 | with pytest.raises(expected_exception=ValueError): | ^^^^^^^^^^ PT011 22 | raise ValueError("Can't divide 1 by 0") @@ -30,7 +29,7 @@ PT011.py:21:43: PT011 `pytest.raises(ValueError)` is too broad, set the `match` PT011.py:24:24: PT011 `pytest.raises(socket.error)` is too broad, set the `match` parameter or use a more specific exception | 22 | raise ValueError("Can't divide 1 by 0") -23 | +23 | 24 | with pytest.raises(socket.error): | ^^^^^^^^^^^^ PT011 25 | raise ValueError("Can't divide 1 by 0") @@ -47,7 +46,7 @@ PT011.py:35:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` PT011.py:38:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception | 36 | raise ValueError("Can't divide 1 by 0") -37 | +37 | 38 | with pytest.raises(ValueError, match=""): | ^^^^^^^^^^ PT011 39 | raise ValueError("Can't divide 1 by 0") @@ -56,7 +55,7 @@ PT011.py:38:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` PT011.py:41:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception | 39 | raise ValueError("Can't divide 1 by 0") -40 | +40 | 41 | with pytest.raises(ValueError, match=f""): | ^^^^^^^^^^ PT011 42 | raise ValueError("Can't divide 1 by 0") diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_glob_all.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_glob_all.snap index 42cd9f1bdb511..eb32dce4b14b8 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_glob_all.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_glob_all.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- PT011.py:13:24: PT011 `pytest.raises(ZeroDivisionError)` is too broad, set the `match` parameter or use a more specific exception | @@ -21,7 +20,7 @@ PT011.py:18:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` PT011.py:21:43: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception | 19 | raise ValueError("Can't divide 1 by 0") -20 | +20 | 21 | with pytest.raises(expected_exception=ValueError): | ^^^^^^^^^^ PT011 22 | raise ValueError("Can't divide 1 by 0") @@ -30,7 +29,7 @@ PT011.py:21:43: PT011 `pytest.raises(ValueError)` is too broad, set the `match` PT011.py:24:24: PT011 `pytest.raises(socket.error)` is too broad, set the `match` parameter or use a more specific exception | 22 | raise ValueError("Can't divide 1 by 0") -23 | +23 | 24 | with pytest.raises(socket.error): | ^^^^^^^^^^^^ PT011 25 | raise ValueError("Can't divide 1 by 0") @@ -39,7 +38,7 @@ PT011.py:24:24: PT011 `pytest.raises(socket.error)` is too broad, set the `match PT011.py:27:24: PT011 `pytest.raises(pickle.PicklingError)` is too broad, set the `match` parameter or use a more specific exception | 25 | raise ValueError("Can't divide 1 by 0") -26 | +26 | 27 | with pytest.raises(PicklingError): | ^^^^^^^^^^^^^ PT011 28 | raise PicklingError("Can't pickle") @@ -48,7 +47,7 @@ PT011.py:27:24: PT011 `pytest.raises(pickle.PicklingError)` is too broad, set th PT011.py:30:24: PT011 `pytest.raises(pickle.UnpicklingError)` is too broad, set the `match` parameter or use a more specific exception | 28 | raise PicklingError("Can't pickle") -29 | +29 | 30 | with pytest.raises(UnpicklingError): | ^^^^^^^^^^^^^^^ PT011 31 | raise UnpicklingError("Can't unpickle") @@ -65,7 +64,7 @@ PT011.py:35:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` PT011.py:38:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception | 36 | raise ValueError("Can't divide 1 by 0") -37 | +37 | 38 | with pytest.raises(ValueError, match=""): | ^^^^^^^^^^ PT011 39 | raise ValueError("Can't divide 1 by 0") @@ -74,7 +73,7 @@ PT011.py:38:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` PT011.py:41:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception | 39 | raise ValueError("Can't divide 1 by 0") -40 | +40 | 41 | with pytest.raises(ValueError, match=f""): | ^^^^^^^^^^ PT011 42 | raise ValueError("Can't divide 1 by 0") diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_glob_prefix.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_glob_prefix.snap index 493e5b2a6fd2a..418c5d5193671 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_glob_prefix.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_glob_prefix.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- PT011.py:27:24: PT011 `pytest.raises(pickle.PicklingError)` is too broad, set the `match` parameter or use a more specific exception | 25 | raise ValueError("Can't divide 1 by 0") -26 | +26 | 27 | with pytest.raises(PicklingError): | ^^^^^^^^^^^^^ PT011 28 | raise PicklingError("Can't pickle") @@ -14,7 +13,7 @@ PT011.py:27:24: PT011 `pytest.raises(pickle.PicklingError)` is too broad, set th PT011.py:30:24: PT011 `pytest.raises(pickle.UnpicklingError)` is too broad, set the `match` parameter or use a more specific exception | 28 | raise PicklingError("Can't pickle") -29 | +29 | 30 | with pytest.raises(UnpicklingError): | ^^^^^^^^^^^^^^^ PT011 31 | raise UnpicklingError("Can't unpickle") diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT013.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT013.snap index 9c7121756e304..b4da53b5275bb 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT013.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT013.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- PT013.py:11:1: PT013 Incorrect import of `pytest`; use `import pytest` instead | 9 | # Error -10 | +10 | 11 | import pytest as other_name | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT013 12 | from pytest import fixture diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_docstring_doubles_all.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_docstring_doubles_all.py.snap index 33c8d75e3fd9b..39a104d5b5a32 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_docstring_doubles_all.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_docstring_doubles_all.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- doubles_all.py:1:1: Q002 [*] Double quote docstring found but single quotes preferred | 1 | """This is a docstring.""" | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 -2 | +2 | 3 | this_is_an_inline_string = "double quote string" | = help: Replace double quotes docstring with single quotes diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_inline_doubles_all.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_inline_doubles_all.py.snap index 380c00dbba5c0..617c8d4d99dce 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_inline_doubles_all.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_inline_doubles_all.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- doubles_all.py:3:28: Q000 [*] Double quotes found but single quotes preferred | 1 | """This is a docstring.""" -2 | +2 | 3 | this_is_an_inline_string = "double quote string" | ^^^^^^^^^^^^^^^^^^^^^ Q000 -4 | +4 | 5 | this_is_a_multiline_string = """ | = help: Replace double quotes with single quotes diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_multiline_doubles_all.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_multiline_doubles_all.py.snap index e290dfc0f2e57..2edceeb830840 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_multiline_doubles_all.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_multiline_doubles_all.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- doubles_all.py:5:30: Q001 [*] Double quote multiline found but single quotes preferred | 3 | this_is_an_inline_string = "double quote string" -4 | +4 | 5 | this_is_a_multiline_string = """ | ______________________________^ 6 | | double quote string diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_class.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_class.py.snap index 5d977b04ba86d..400d7ae38e61f 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_class.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_class.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- docstring_doubles_class.py:3:5: Q001 [*] Double quote multiline found but single quotes preferred | @@ -8,7 +7,7 @@ docstring_doubles_class.py:3:5: Q001 [*] Double quote multiline found but single 2 | """ Double quotes single line class docstring """ 3 | """ Not a docstring """ | ^^^^^^^^^^^^^^^^^^^^^^^ Q001 -4 | +4 | 5 | def foo(self, bar="""not a docstring"""): | = help: Replace double multiline quotes with single quotes @@ -25,7 +24,7 @@ docstring_doubles_class.py:3:5: Q001 [*] Double quote multiline found but single docstring_doubles_class.py:5:23: Q001 [*] Double quote multiline found but single quotes preferred | 3 | """ Not a docstring """ -4 | +4 | 5 | def foo(self, bar="""not a docstring"""): | ^^^^^^^^^^^^^^^^^^^^^ Q001 6 | """ Double quotes single line method docstring""" diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_singleline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_singleline.py.snap index 5d6f9808ebec1..b4aa9a7b1fbd7 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_singleline.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_singleline.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- docstring_doubles_module_singleline.py:2:1: Q001 [*] Double quote multiline found but single quotes preferred | 1 | """ Double quotes singleline module docstring """ 2 | """ this is not a docstring """ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q001 -3 | +3 | 4 | def foo(): | = help: Replace double multiline quotes with single quotes diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_class.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_class.py.snap index 9b31ff68664ab..b384b9e645f75 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_class.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_class.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- docstring_singles_class.py:2:5: Q002 [*] Single quote docstring found but double quotes preferred | @@ -41,7 +40,7 @@ docstring_singles_class.py:6:9: Q002 [*] Single quote docstring found but double docstring_singles_class.py:9:29: Q002 [*] Single quote docstring found but double quotes preferred | 7 | pass -8 | +8 | 9 | class Nested(foo()[:]): ''' inline docstring '''; pass | ^^^^^^^^^^^^^^^^^^^^^^^^ Q002 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_1.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_1.py.snap index 89dbadf0136eb..d231495a1133c 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_1.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- docstring_singles_mixed_quotes_class_var_1.py:2:5: Q002 Single quote docstring found but double quotes preferred | @@ -59,7 +58,7 @@ docstring_singles_mixed_quotes_class_var_1.py:6:37: Q002 [*] Single quote docstr docstring_singles_mixed_quotes_class_var_1.py:9:29: Q002 Single quote docstring found but double quotes preferred | 7 | pass -8 | +8 | 9 | class Nested(foo()[:]): ''"Start with empty string" ' and lint docstring safely'; pass | ^^ Q002 | @@ -68,7 +67,7 @@ docstring_singles_mixed_quotes_class_var_1.py:9:29: Q002 Single quote docstring docstring_singles_mixed_quotes_class_var_1.py:9:57: Q002 [*] Single quote docstring found but double quotes preferred | 7 | pass -8 | +8 | 9 | class Nested(foo()[:]): ''"Start with empty string" ' and lint docstring safely'; pass | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_2.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_2.py.snap index ee86ebe457f93..1346b4f188a99 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_2.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- docstring_singles_mixed_quotes_class_var_2.py:2:5: Q002 [*] Single quote docstring found but double quotes preferred | @@ -77,7 +76,7 @@ docstring_singles_mixed_quotes_class_var_2.py:6:44: Q002 [*] Single quote docstr docstring_singles_mixed_quotes_class_var_2.py:9:29: Q002 [*] Single quote docstring found but double quotes preferred | 7 | pass -8 | +8 | 9 | class Nested(foo()[:]): 'Do not'" start with empty string" ' and lint docstring safely'; pass | ^^^^^^^^ Q002 | @@ -93,7 +92,7 @@ docstring_singles_mixed_quotes_class_var_2.py:9:29: Q002 [*] Single quote docstr docstring_singles_mixed_quotes_class_var_2.py:9:64: Q002 [*] Single quote docstring found but double quotes preferred | 7 | pass -8 | +8 | 9 | class Nested(foo()[:]): 'Do not'" start with empty string" ' and lint docstring safely'; pass | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_1.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_1.py.snap index 0d3786a62094c..298bf7a6d184f 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_1.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- docstring_singles_mixed_quotes_module_singleline_var_1.py:1:1: Q002 Single quote docstring found but double quotes preferred | 1 | ''"Start with empty string" ' and lint docstring safely' | ^^ Q002 -2 | +2 | 3 | def foo(): | = help: Replace single quotes docstring with double quotes @@ -15,7 +14,7 @@ docstring_singles_mixed_quotes_module_singleline_var_1.py:1:29: Q002 [*] Single | 1 | ''"Start with empty string" ' and lint docstring safely' | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 -2 | +2 | 3 | def foo(): | = help: Replace single quotes docstring with double quotes diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_2.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_2.py.snap index 9037e28bbeb2c..1faa802f1bb57 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_2.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- docstring_singles_mixed_quotes_module_singleline_var_2.py:1:1: Q002 [*] Single quote docstring found but double quotes preferred | 1 | 'Do not'" start with empty string" ' and lint docstring safely' | ^^^^^^^^ Q002 -2 | +2 | 3 | def foo(): | = help: Replace single quotes docstring with double quotes @@ -22,7 +21,7 @@ docstring_singles_mixed_quotes_module_singleline_var_2.py:1:36: Q002 [*] Single | 1 | 'Do not'" start with empty string" ' and lint docstring safely' | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 -2 | +2 | 3 | def foo(): | = help: Replace single quotes docstring with double quotes diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_class.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_class.py.snap index 6c9201b6d2177..e222557186f39 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_class.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_class.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- docstring_doubles_class.py:2:5: Q002 [*] Double quote docstring found but single quotes preferred | @@ -41,7 +40,7 @@ docstring_doubles_class.py:6:9: Q002 [*] Double quote docstring found but single docstring_doubles_class.py:9:29: Q002 [*] Double quote docstring found but single quotes preferred | 7 | pass -8 | +8 | 9 | class Nested(foo()[:]): """ inline docstring """; pass | ^^^^^^^^^^^^^^^^^^^^^^^^ Q002 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_class_var_1.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_class_var_1.py.snap index 8df5f7f4ee0f9..34ed1310df5da 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_class_var_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_class_var_1.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- docstring_doubles_mixed_quotes_class_var_1.py:2:5: Q002 Double quote docstring found but single quotes preferred | @@ -23,7 +22,7 @@ docstring_doubles_mixed_quotes_class_var_1.py:6:9: Q002 Double quote docstring f docstring_doubles_mixed_quotes_class_var_1.py:9:29: Q002 Double quote docstring found but single quotes preferred | 7 | pass -8 | +8 | 9 | class Nested(foo()[:]): ""'Start with empty string' ' and lint docstring safely'; pass | ^^ Q002 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_class_var_2.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_class_var_2.py.snap index eef897e8a4c99..a9b6c90379e0a 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_class_var_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_class_var_2.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- docstring_doubles_mixed_quotes_class_var_2.py:2:5: Q002 [*] Double quote docstring found but single quotes preferred | @@ -41,7 +40,7 @@ docstring_doubles_mixed_quotes_class_var_2.py:6:9: Q002 [*] Double quote docstri docstring_doubles_mixed_quotes_class_var_2.py:9:29: Q002 [*] Double quote docstring found but single quotes preferred | 7 | pass -8 | +8 | 9 | class Nested(foo()[:]): "Do not"' start with empty string' ' and lint docstring safely'; pass | ^^^^^^^^ Q002 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_module_singleline_var_1.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_module_singleline_var_1.py.snap index 77d174d8717a7..e19a8dabb23bc 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_module_singleline_var_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_module_singleline_var_1.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- docstring_doubles_mixed_quotes_module_singleline_var_1.py:1:1: Q002 Double quote docstring found but single quotes preferred | 1 | ""'Start with empty string' ' and lint docstring safely' | ^^ Q002 -2 | +2 | 3 | def foo(): | = help: Replace double quotes docstring with single quotes diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_module_singleline_var_2.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_module_singleline_var_2.py.snap index 8ff2ea1de0dcf..81295100babcc 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_module_singleline_var_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_module_singleline_var_2.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- docstring_doubles_mixed_quotes_module_singleline_var_2.py:1:1: Q002 [*] Double quote docstring found but single quotes preferred | 1 | "Do not"' start with empty string' ' and lint docstring safely' | ^^^^^^^^ Q002 -2 | +2 | 3 | def foo(): | = help: Replace double quotes docstring with single quotes diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_class.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_class.py.snap index b995da2bde38a..d94db3e564b7c 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_class.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_class.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- docstring_singles_class.py:3:5: Q001 [*] Single quote multiline found but double quotes preferred | @@ -8,7 +7,7 @@ docstring_singles_class.py:3:5: Q001 [*] Single quote multiline found but double 2 | ''' Double quotes single line class docstring ''' 3 | ''' Not a docstring ''' | ^^^^^^^^^^^^^^^^^^^^^^^ Q001 -4 | +4 | 5 | def foo(self, bar='''not a docstring'''): | = help: Replace single multiline quotes with double quotes @@ -25,7 +24,7 @@ docstring_singles_class.py:3:5: Q001 [*] Single quote multiline found but double docstring_singles_class.py:5:23: Q001 [*] Single quote multiline found but double quotes preferred | 3 | ''' Not a docstring ''' -4 | +4 | 5 | def foo(self, bar='''not a docstring'''): | ^^^^^^^^^^^^^^^^^^^^^ Q001 6 | ''' Double quotes single line method docstring''' diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_singleline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_singleline.py.snap index 907da2954acb7..85b17d1d403bb 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_singleline.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_singleline.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- docstring_singles_module_singleline.py:2:1: Q001 [*] Single quote multiline found but double quotes preferred | 1 | ''' Double quotes singleline module docstring ''' 2 | ''' this is not a docstring ''' | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q001 -3 | +3 | 4 | def foo(): | = help: Replace single multiline quotes with double quotes diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped.py.snap index b039517bb1c68..a1099a8e0b323 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- singles_escaped.py:1:26: Q003 [*] Change outer quotes to avoid escaping inner quotes | @@ -125,7 +124,7 @@ singles_escaped.py:33:1: Q003 [*] Change outer quotes to avoid escaping inner qu 32 | f"\"foo\" {f"foo"}" # Q003 33 | f"\"foo\" {f"\"foo\""} \"\"" # Q003 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 -34 | +34 | 35 | f"normal {f"nested"} normal" | = help: Change outer quotes to avoid escaping inner quotes @@ -146,7 +145,7 @@ singles_escaped.py:33:12: Q003 [*] Change outer quotes to avoid escaping inner q 32 | f"\"foo\" {f"foo"}" # Q003 33 | f"\"foo\" {f"\"foo\""} \"\"" # Q003 | ^^^^^^^^^^ Q003 -34 | +34 | 35 | f"normal {f"nested"} normal" | = help: Change outer quotes to avoid escaping inner quotes diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped_unnecessary.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped_unnecessary.py.snap index abc266c1552af..71e3d38d97115 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped_unnecessary.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped_unnecessary.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- singles_escaped_unnecessary.py:1:26: Q004 [*] Unnecessary escape on inner quote character | @@ -164,7 +163,7 @@ singles_escaped_unnecessary.py:33:1: Q004 [*] Unnecessary escape on inner quote 32 | f"\'foo\' {f"foo"}" # Q004 33 | f"\'foo\' {f"\'foo\'"} \'\'" # Q004 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 -34 | +34 | 35 | f"normal {f"nested"} normal" | = help: Remove backslash @@ -185,7 +184,7 @@ singles_escaped_unnecessary.py:33:12: Q004 [*] Unnecessary escape on inner quote 32 | f"\'foo\' {f"foo"}" # Q004 33 | f"\'foo\' {f"\'foo\'"} \'\'" # Q004 | ^^^^^^^^^^ Q004 -34 | +34 | 35 | f"normal {f"nested"} normal" | = help: Remove backslash @@ -287,7 +286,7 @@ singles_escaped_unnecessary.py:39:1: Q004 [*] Unnecessary escape on inner quote 38 | f"\'normal\' {f"\'nested\' {"other"} normal"} 'single quotes'" # Q004 39 | f"\'normal\' {f"\'nested\' {"other"} 'single quotes'"} normal" # Q004 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 -40 | +40 | 41 | # Make sure we do not unescape quotes | = help: Remove backslash @@ -308,7 +307,7 @@ singles_escaped_unnecessary.py:39:15: Q004 [*] Unnecessary escape on inner quote 38 | f"\'normal\' {f"\'nested\' {"other"} normal"} 'single quotes'" # Q004 39 | f"\'normal\' {f"\'nested\' {"other"} 'single quotes'"} normal" # Q004 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 -40 | +40 | 41 | # Make sure we do not unescape quotes | = help: Remove backslash @@ -329,7 +328,7 @@ singles_escaped_unnecessary.py:43:26: Q004 [*] Unnecessary escape on inner quote 42 | this_is_fine = "This is an \\'escaped\\' quote" 43 | this_should_raise_Q004 = "This is an \\\'escaped\\\' quote with an extra backslash" # Q004 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 -44 | +44 | 45 | # Invalid escapes in bytestrings are also triggered: | = help: Remove backslash diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_multiline_string.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_multiline_string.py.snap index ae82ed4e51d08..d926ca1c410d2 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_multiline_string.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_multiline_string.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- singles_multiline_string.py:1:5: Q001 [*] Single quote multiline found but double quotes preferred | @@ -9,7 +8,7 @@ singles_multiline_string.py:1:5: Q001 [*] Single quote multiline found but doubl 2 | | be 3 | | 'linted' ''' | |____________^ Q001 -4 | +4 | 5 | s = """ This 'should' | = help: Replace single multiline quotes with double quotes diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped.py.snap index 11f9ea26d429b..feff195fb7e75 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- doubles_escaped.py:1:26: Q003 [*] Change outer quotes to avoid escaping inner quotes | @@ -164,7 +163,7 @@ doubles_escaped.py:35:1: Q003 [*] Change outer quotes to avoid escaping inner qu 34 | f'\'foo\' {f'nested'}' # Q003 35 | f'\'foo\' {f'\'nested\''} \'\'' # Q003 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 -36 | +36 | 37 | f'normal {f'nested'} normal' | = help: Change outer quotes to avoid escaping inner quotes @@ -185,7 +184,7 @@ doubles_escaped.py:35:12: Q003 [*] Change outer quotes to avoid escaping inner q 34 | f'\'foo\' {f'nested'}' # Q003 35 | f'\'foo\' {f'\'nested\''} \'\'' # Q003 | ^^^^^^^^^^^^^ Q003 -36 | +36 | 37 | f'normal {f'nested'} normal' | = help: Change outer quotes to avoid escaping inner quotes diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped_unnecessary.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped_unnecessary.py.snap index 23715cd437879..3cf6da94bb002 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped_unnecessary.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped_unnecessary.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- doubles_escaped_unnecessary.py:1:26: Q004 [*] Unnecessary escape on inner quote character | @@ -205,7 +204,7 @@ doubles_escaped_unnecessary.py:35:1: Q004 [*] Unnecessary escape on inner quote 34 | f'\"foo\" {f'nested'}' # Q004 35 | f'\"foo\" {f'\"nested\"'} \"\"' # Q004 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 -36 | +36 | 37 | f'normal {f'nested'} normal' | = help: Remove backslash @@ -226,7 +225,7 @@ doubles_escaped_unnecessary.py:35:12: Q004 [*] Unnecessary escape on inner quote 34 | f'\"foo\" {f'nested'}' # Q004 35 | f'\"foo\" {f'\"nested\"'} \"\"' # Q004 | ^^^^^^^^^^^^^ Q004 -36 | +36 | 37 | f'normal {f'nested'} normal' | = help: Remove backslash @@ -328,7 +327,7 @@ doubles_escaped_unnecessary.py:41:1: Q004 [*] Unnecessary escape on inner quote 40 | f'\"normal\" {f'\"nested\" {'other'} normal'} "double quotes"' # Q004 41 | f'\"normal\" {f'\"nested\" {'other'} "double quotes"'} normal' # Q004 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 -42 | +42 | 43 | # Make sure we do not unescape quotes | = help: Remove backslash @@ -349,7 +348,7 @@ doubles_escaped_unnecessary.py:41:15: Q004 [*] Unnecessary escape on inner quote 40 | f'\"normal\" {f'\"nested\" {'other'} normal'} "double quotes"' # Q004 41 | f'\"normal\" {f'\"nested\" {'other'} "double quotes"'} normal' # Q004 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 -42 | +42 | 43 | # Make sure we do not unescape quotes | = help: Remove backslash diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_multiline_string.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_multiline_string.py.snap index 3f3941f8421ae..7d40683d00973 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_multiline_string.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_multiline_string.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- doubles_multiline_string.py:1:5: Q001 [*] Double quote multiline found but single quotes preferred | @@ -9,7 +8,7 @@ doubles_multiline_string.py:1:5: Q001 [*] Double quote multiline found but singl 2 | | be 3 | | "linted" """ | |____________^ Q001 -4 | +4 | 5 | s = ''' This "should" | = help: Replace double multiline quotes with single quotes diff --git a/crates/ruff_linter/src/rules/flake8_raise/snapshots/ruff_linter__rules__flake8_raise__tests__unnecessary-paren-on-raise-exception_RSE102.py.snap b/crates/ruff_linter/src/rules/flake8_raise/snapshots/ruff_linter__rules__flake8_raise__tests__unnecessary-paren-on-raise-exception_RSE102.py.snap index be7643462e394..80d7448df1fca 100644 --- a/crates/ruff_linter/src/rules/flake8_raise/snapshots/ruff_linter__rules__flake8_raise__tests__unnecessary-paren-on-raise-exception_RSE102.py.snap +++ b/crates/ruff_linter/src/rules/flake8_raise/snapshots/ruff_linter__rules__flake8_raise__tests__unnecessary-paren-on-raise-exception_RSE102.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_raise/mod.rs -snapshot_kind: text --- RSE102.py:5:21: RSE102 [*] Unnecessary parentheses on raised exception | @@ -8,7 +7,7 @@ RSE102.py:5:21: RSE102 [*] Unnecessary parentheses on raised exception 4 | # RSE102 5 | raise ValueError() | ^^ RSE102 -6 | +6 | 7 | try: | = help: Remove unnecessary parentheses @@ -28,7 +27,7 @@ RSE102.py:13:16: RSE102 [*] Unnecessary parentheses on raised exception 12 | # RSE102 13 | raise TypeError() | ^^ RSE102 -14 | +14 | 15 | # RSE102 | = help: Remove unnecessary parentheses @@ -48,7 +47,7 @@ RSE102.py:16:17: RSE102 [*] Unnecessary parentheses on raised exception 15 | # RSE102 16 | raise TypeError () | ^^ RSE102 -17 | +17 | 18 | # RSE102 | = help: Remove unnecessary parentheses @@ -69,7 +68,7 @@ RSE102.py:20:5: RSE102 [*] Unnecessary parentheses on raised exception 19 | raise TypeError \ 20 | () | ^^ RSE102 -21 | +21 | 22 | # RSE102 | = help: Remove unnecessary parentheses @@ -90,7 +89,7 @@ RSE102.py:24:5: RSE102 [*] Unnecessary parentheses on raised exception 23 | raise TypeError \ 24 | (); | ^^ RSE102 -25 | +25 | 26 | # RSE102 | = help: Remove unnecessary parentheses @@ -110,10 +109,10 @@ RSE102.py:27:16: RSE102 [*] Unnecessary parentheses on raised exception 26 | # RSE102 27 | raise TypeError( | ________________^ -28 | | +28 | | 29 | | ) | |_^ RSE102 -30 | +30 | 31 | # RSE102 | = help: Remove unnecessary parentheses @@ -135,10 +134,10 @@ RSE102.py:32:19: RSE102 [*] Unnecessary parentheses on raised exception 31 | # RSE102 32 | raise (TypeError) ( | ___________________^ -33 | | +33 | | 34 | | ) | |_^ RSE102 -35 | +35 | 36 | # RSE102 | = help: Remove unnecessary parentheses @@ -163,7 +162,7 @@ RSE102.py:37:16: RSE102 [*] Unnecessary parentheses on raised exception 38 | | # Hello, world! 39 | | ) | |_^ RSE102 -40 | +40 | 41 | # OK | = help: Remove unnecessary parentheses @@ -185,7 +184,7 @@ RSE102.py:74:17: RSE102 [*] Unnecessary parentheses on raised exception 73 | # RSE102 74 | raise IndexError()from ZeroDivisionError | ^^ RSE102 -75 | +75 | 76 | raise IndexError()\ | = help: Remove unnecessary parentheses @@ -203,7 +202,7 @@ RSE102.py:74:17: RSE102 [*] Unnecessary parentheses on raised exception RSE102.py:76:17: RSE102 [*] Unnecessary parentheses on raised exception | 74 | raise IndexError()from ZeroDivisionError -75 | +75 | 76 | raise IndexError()\ | ^^ RSE102 77 | from ZeroDivisionError @@ -223,10 +222,10 @@ RSE102.py:76:17: RSE102 [*] Unnecessary parentheses on raised exception RSE102.py:79:17: RSE102 [*] Unnecessary parentheses on raised exception | 77 | from ZeroDivisionError -78 | +78 | 79 | raise IndexError() from ZeroDivisionError | ^^ RSE102 -80 | +80 | 81 | raise IndexError(); | = help: Remove unnecessary parentheses @@ -244,10 +243,10 @@ RSE102.py:79:17: RSE102 [*] Unnecessary parentheses on raised exception RSE102.py:81:17: RSE102 [*] Unnecessary parentheses on raised exception | 79 | raise IndexError() from ZeroDivisionError -80 | +80 | 81 | raise IndexError(); | ^^ RSE102 -82 | +82 | 83 | # RSE102 | = help: Remove unnecessary parentheses @@ -267,7 +266,7 @@ RSE102.py:84:10: RSE102 [*] Unnecessary parentheses on raised exception 83 | # RSE102 84 | raise Foo() | ^^ RSE102 -85 | +85 | 86 | # OK | = help: Remove unnecessary parentheses diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET501_RET501.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET501_RET501.py.snap index 7660c5d800fbc..0dcc8a8491d50 100644 --- a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET501_RET501.py.snap +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET501_RET501.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_return/mod.rs -snapshot_kind: text --- RET501.py:4:5: RET501 [*] Do not explicitly `return None` in function if it is the only possible return value | @@ -27,7 +26,7 @@ RET501.py:14:9: RET501 [*] Do not explicitly `return None` in function if it is 13 | print(f"{key} not found") 14 | return None | ^^^^^^^^^^^ RET501 -15 | +15 | 16 | @property | = help: Remove explicit `return None` diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET505_RET505.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET505_RET505.py.snap index 5e412cfef1f60..132296938a59a 100644 --- a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET505_RET505.py.snap +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET505_RET505.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_return/mod.rs -snapshot_kind: text --- RET505.py:8:5: RET505 [*] Unnecessary `elif` after `return` statement | @@ -369,7 +368,7 @@ RET505.py:207:5: RET505 [*] Unnecessary `else` after `return` statement 206 | return y 207 | else: | ^^^^ RET505 -208 | +208 | 209 | c = 3 | = help: Remove unnecessary `else` diff --git a/crates/ruff_linter/src/rules/flake8_self/snapshots/ruff_linter__rules__flake8_self__tests__private-member-access_SLF001.py.snap b/crates/ruff_linter/src/rules/flake8_self/snapshots/ruff_linter__rules__flake8_self__tests__private-member-access_SLF001.py.snap index 7dedeb769da92..edd0ef3dd2f7d 100644 --- a/crates/ruff_linter/src/rules/flake8_self/snapshots/ruff_linter__rules__flake8_self__tests__private-member-access_SLF001.py.snap +++ b/crates/ruff_linter/src/rules/flake8_self/snapshots/ruff_linter__rules__flake8_self__tests__private-member-access_SLF001.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_self/mod.rs -snapshot_kind: text --- SLF001.py:34:12: SLF001 Private member accessed: `_private` | @@ -44,7 +43,7 @@ SLF001.py:43:12: SLF001 Private member accessed: `_private_thing` SLF001.py:62:7: SLF001 Private member accessed: `_private_thing` | 60 | foo = Foo() -61 | +61 | 62 | print(foo._private_thing) # SLF001 | ^^^^^^^^^^^^^^^^^^ SLF001 63 | print(foo.__really_private_thing) # SLF001 @@ -105,6 +104,6 @@ SLF001.py:68:7: SLF001 Private member accessed: `_private_thing__` 67 | print(foo()._private_thing) # SLF001 68 | print(foo()._private_thing__) # SLF001 | ^^^^^^^^^^^^^^^^^^^^^^ SLF001 -69 | +69 | 70 | print(foo.public_thing) | diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM101_SIM101.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM101_SIM101.py.snap index 0a3979e46f9f3..68fe445fbb55a 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM101_SIM101.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM101_SIM101.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM101.py:1:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call | @@ -20,7 +19,7 @@ SIM101.py:1:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a sing SIM101.py:4:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call | 2 | pass -3 | +3 | 4 | if isinstance(a, (int, float)) or isinstance(a, bool): # SIM101 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 5 | pass @@ -40,7 +39,7 @@ SIM101.py:4:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a sing SIM101.py:7:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call | 5 | pass -6 | +6 | 7 | if isinstance(a, int) or isinstance(a, float) or isinstance(b, bool): # SIM101 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 8 | pass @@ -60,7 +59,7 @@ SIM101.py:7:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a sing SIM101.py:10:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call | 8 | pass - 9 | + 9 | 10 | if isinstance(b, bool) or isinstance(a, int) or isinstance(a, float): # SIM101 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 11 | pass @@ -80,7 +79,7 @@ SIM101.py:10:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a sin SIM101.py:16:5: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call | 14 | pass -15 | +15 | 16 | if (isinstance(a, int) or isinstance(a, float)) and isinstance(b, bool): # SIM101 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 17 | pass @@ -100,7 +99,7 @@ SIM101.py:16:5: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a sin SIM101.py:19:4: SIM101 [*] Multiple `isinstance` calls for expression, merge into a single call | 17 | pass -18 | +18 | 19 | if isinstance(a.b, int) or isinstance(a.b, float): # SIM101 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 20 | pass @@ -120,7 +119,7 @@ SIM101.py:19:4: SIM101 [*] Multiple `isinstance` calls for expression, merge int SIM101.py:22:4: SIM101 Multiple `isinstance` calls for expression, merge into a single call | 20 | pass -21 | +21 | 22 | if isinstance(a(), int) or isinstance(a(), float): # SIM101 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 23 | pass @@ -130,7 +129,7 @@ SIM101.py:22:4: SIM101 Multiple `isinstance` calls for expression, merge into a SIM101.py:38:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call | 36 | pass -37 | +37 | 38 | if x or isinstance(a, int) or isinstance(a, float): | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 39 | pass @@ -150,7 +149,7 @@ SIM101.py:38:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a sin SIM101.py:41:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call | 39 | pass -40 | +40 | 41 | if x or y or isinstance(a, int) or isinstance(a, float) or z: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 42 | pass diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM112_SIM112.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM112_SIM112.py.snap index d077e70063116..ac36a3bf67e63 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM112_SIM112.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM112_SIM112.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM112.py:4:12: SIM112 [*] Use capitalized environment variable `FOO` instead of `foo` | 3 | # Bad 4 | os.environ['foo'] | ^^^^^ SIM112 -5 | +5 | 6 | os.environ.get('foo') | = help: Replace `foo` with `FOO` @@ -25,10 +24,10 @@ SIM112.py:4:12: SIM112 [*] Use capitalized environment variable `FOO` instead of SIM112.py:6:16: SIM112 Use capitalized environment variable `FOO` instead of `foo` | 4 | os.environ['foo'] -5 | +5 | 6 | os.environ.get('foo') | ^^^^^ SIM112 -7 | +7 | 8 | os.environ.get('foo', 'bar') | = help: Replace `foo` with `FOO` @@ -36,10 +35,10 @@ SIM112.py:6:16: SIM112 Use capitalized environment variable `FOO` instead of `fo SIM112.py:8:16: SIM112 Use capitalized environment variable `FOO` instead of `foo` | 6 | os.environ.get('foo') - 7 | + 7 | 8 | os.environ.get('foo', 'bar') | ^^^^^ SIM112 - 9 | + 9 | 10 | os.getenv('foo') | = help: Replace `foo` with `FOO` @@ -47,10 +46,10 @@ SIM112.py:8:16: SIM112 Use capitalized environment variable `FOO` instead of `fo SIM112.py:10:11: SIM112 Use capitalized environment variable `FOO` instead of `foo` | 8 | os.environ.get('foo', 'bar') - 9 | + 9 | 10 | os.getenv('foo') | ^^^^^ SIM112 -11 | +11 | 12 | env = os.environ.get('foo') | = help: Replace `foo` with `FOO` @@ -58,10 +57,10 @@ SIM112.py:10:11: SIM112 Use capitalized environment variable `FOO` instead of `f SIM112.py:12:22: SIM112 Use capitalized environment variable `FOO` instead of `foo` | 10 | os.getenv('foo') -11 | +11 | 12 | env = os.environ.get('foo') | ^^^^^ SIM112 -13 | +13 | 14 | env = os.environ['foo'] | = help: Replace `foo` with `FOO` @@ -69,10 +68,10 @@ SIM112.py:12:22: SIM112 Use capitalized environment variable `FOO` instead of `f SIM112.py:14:18: SIM112 [*] Use capitalized environment variable `FOO` instead of `foo` | 12 | env = os.environ.get('foo') -13 | +13 | 14 | env = os.environ['foo'] | ^^^^^ SIM112 -15 | +15 | 16 | if env := os.environ.get('foo'): | = help: Replace `foo` with `FOO` @@ -90,7 +89,7 @@ SIM112.py:14:18: SIM112 [*] Use capitalized environment variable `FOO` instead o SIM112.py:16:26: SIM112 Use capitalized environment variable `FOO` instead of `foo` | 14 | env = os.environ['foo'] -15 | +15 | 16 | if env := os.environ.get('foo'): | ^^^^^ SIM112 17 | pass @@ -100,7 +99,7 @@ SIM112.py:16:26: SIM112 Use capitalized environment variable `FOO` instead of `f SIM112.py:19:22: SIM112 [*] Use capitalized environment variable `FOO` instead of `foo` | 17 | pass -18 | +18 | 19 | if env := os.environ['foo']: | ^^^^^ SIM112 20 | pass diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM115_SIM115.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM115_SIM115.py.snap index 445f6766941d8..551ddd03158b6 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM115_SIM115.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM115_SIM115.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM115.py:8:5: SIM115 Use a context manager for opening files | @@ -57,14 +56,14 @@ SIM115.py:39:9: SIM115 Use a context manager for opening files 38 | with contextlib.ExitStack(): 39 | f = open("filename") | ^^^^ SIM115 -40 | +40 | 41 | # OK | SIM115.py:80:5: SIM115 Use a context manager for opening files | 78 | import fileinput -79 | +79 | 80 | f = tempfile.NamedTemporaryFile() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM115 81 | f = tempfile.TemporaryFile() @@ -305,7 +304,7 @@ SIM115.py:104:5: SIM115 Use a context manager for opening files 103 | f = fileinput.input("foo.txt") 104 | f = fileinput.FileInput("foo.txt") | ^^^^^^^^^^^^^^^^^^^ SIM115 -105 | +105 | 106 | with contextlib.suppress(Exception): | diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM116_SIM116.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM116_SIM116.py.snap index fb7742657c62f..844e1906b4b95 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM116_SIM116.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM116_SIM116.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM116.py:5:1: SIM116 Use a dictionary instead of consecutive `if` statements | @@ -14,7 +13,7 @@ SIM116.py:5:1: SIM116 Use a dictionary instead of consecutive `if` statements 11 | | else: 12 | | return 42 | |_____________^ SIM116 -13 | +13 | 14 | # SIM116 | @@ -30,7 +29,7 @@ SIM116.py:15:1: SIM116 Use a dictionary instead of consecutive `if` statements 21 | | else: 22 | | return (10, 11, 12) | |_______________________^ SIM116 -23 | +23 | 24 | # SIM116 | @@ -44,7 +43,7 @@ SIM116.py:25:1: SIM116 Use a dictionary instead of consecutive `if` statements 29 | | elif a == 3: 30 | | return (7, 8, 9) | |____________________^ SIM116 -31 | +31 | 32 | # SIM116 | @@ -60,7 +59,7 @@ SIM116.py:33:1: SIM116 Use a dictionary instead of consecutive `if` statements 39 | | else: 40 | | return (10, 11, 12) | |_______________________^ SIM116 -41 | +41 | 42 | # SIM116 | @@ -74,7 +73,7 @@ SIM116.py:43:1: SIM116 Use a dictionary instead of consecutive `if` statements 47 | | elif a == b"three": 48 | | return 3 | |____________^ SIM116 -49 | +49 | 50 | # SIM116 | @@ -90,7 +89,7 @@ SIM116.py:51:1: SIM116 Use a dictionary instead of consecutive `if` statements 57 | | else: 58 | | return (10, 11, 12) | |_______________________^ SIM116 -59 | +59 | 60 | # OK | @@ -106,6 +105,6 @@ SIM116.py:79:1: SIM116 Use a dictionary instead of consecutive `if` statements 85 | | elif func_name == "move": 86 | | return "MV" | |_______________^ SIM116 -87 | +87 | 88 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM118_SIM118.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM118_SIM118.py.snap index 2251effdcd8d3..28b8ed5313248 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM118_SIM118.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM118_SIM118.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM118.py:3:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 1 | obj = {} -2 | +2 | 3 | key in obj.keys() # SIM118 | ^^^^^^^^^^^^^^^^^ SIM118 -4 | +4 | 5 | key not in obj.keys() # SIM118 | = help: Remove `.keys()` @@ -25,10 +24,10 @@ SIM118.py:3:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` SIM118.py:5:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` | 3 | key in obj.keys() # SIM118 -4 | +4 | 5 | key not in obj.keys() # SIM118 | ^^^^^^^^^^^^^^^^^^^^^ SIM118 -6 | +6 | 7 | foo["bar"] in obj.keys() # SIM118 | = help: Remove `.keys()` @@ -46,10 +45,10 @@ SIM118.py:5:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys SIM118.py:7:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 5 | key not in obj.keys() # SIM118 -6 | +6 | 7 | foo["bar"] in obj.keys() # SIM118 | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 -8 | +8 | 9 | foo["bar"] not in obj.keys() # SIM118 | = help: Remove `.keys()` @@ -67,10 +66,10 @@ SIM118.py:7:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` SIM118.py:9:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` | 7 | foo["bar"] in obj.keys() # SIM118 - 8 | + 8 | 9 | foo["bar"] not in obj.keys() # SIM118 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 -10 | +10 | 11 | foo['bar'] in obj.keys() # SIM118 | = help: Remove `.keys()` @@ -88,10 +87,10 @@ SIM118.py:9:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys SIM118.py:11:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 9 | foo["bar"] not in obj.keys() # SIM118 -10 | +10 | 11 | foo['bar'] in obj.keys() # SIM118 | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 -12 | +12 | 13 | foo['bar'] not in obj.keys() # SIM118 | = help: Remove `.keys()` @@ -109,10 +108,10 @@ SIM118.py:11:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` SIM118.py:13:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` | 11 | foo['bar'] in obj.keys() # SIM118 -12 | +12 | 13 | foo['bar'] not in obj.keys() # SIM118 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 -14 | +14 | 15 | foo() in obj.keys() # SIM118 | = help: Remove `.keys()` @@ -130,10 +129,10 @@ SIM118.py:13:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.key SIM118.py:15:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 13 | foo['bar'] not in obj.keys() # SIM118 -14 | +14 | 15 | foo() in obj.keys() # SIM118 | ^^^^^^^^^^^^^^^^^^^ SIM118 -16 | +16 | 17 | foo() not in obj.keys() # SIM118 | = help: Remove `.keys()` @@ -151,10 +150,10 @@ SIM118.py:15:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` SIM118.py:17:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` | 15 | foo() in obj.keys() # SIM118 -16 | +16 | 17 | foo() not in obj.keys() # SIM118 | ^^^^^^^^^^^^^^^^^^^^^^^ SIM118 -18 | +18 | 19 | for key in obj.keys(): # SIM118 | = help: Remove `.keys()` @@ -172,7 +171,7 @@ SIM118.py:17:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.key SIM118.py:19:5: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 17 | foo() not in obj.keys() # SIM118 -18 | +18 | 19 | for key in obj.keys(): # SIM118 | ^^^^^^^^^^^^^^^^^ SIM118 20 | pass @@ -192,10 +191,10 @@ SIM118.py:19:5: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` SIM118.py:26:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 24 | del obj[key] -25 | +25 | 26 | [k for k in obj.keys()] # SIM118 | ^^^^^^^^^^^^^^^ SIM118 -27 | +27 | 28 | {k for k in obj.keys()} # SIM118 | = help: Remove `.keys()` @@ -213,10 +212,10 @@ SIM118.py:26:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` SIM118.py:28:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 26 | [k for k in obj.keys()] # SIM118 -27 | +27 | 28 | {k for k in obj.keys()} # SIM118 | ^^^^^^^^^^^^^^^ SIM118 -29 | +29 | 30 | {k: k for k in obj.keys()} # SIM118 | = help: Remove `.keys()` @@ -234,10 +233,10 @@ SIM118.py:28:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` SIM118.py:30:11: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 28 | {k for k in obj.keys()} # SIM118 -29 | +29 | 30 | {k: k for k in obj.keys()} # SIM118 | ^^^^^^^^^^^^^^^ SIM118 -31 | +31 | 32 | (k for k in obj.keys()) # SIM118 | = help: Remove `.keys()` @@ -255,10 +254,10 @@ SIM118.py:30:11: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` SIM118.py:32:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 30 | {k: k for k in obj.keys()} # SIM118 -31 | +31 | 32 | (k for k in obj.keys()) # SIM118 | ^^^^^^^^^^^^^^^ SIM118 -33 | +33 | 34 | key in (obj or {}).keys() # SIM118 | = help: Remove `.keys()` @@ -276,10 +275,10 @@ SIM118.py:32:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` SIM118.py:34:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 32 | (k for k in obj.keys()) # SIM118 -33 | +33 | 34 | key in (obj or {}).keys() # SIM118 | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 -35 | +35 | 36 | (key) in (obj or {}).keys() # SIM118 | = help: Remove `.keys()` @@ -297,10 +296,10 @@ SIM118.py:34:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` SIM118.py:36:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 34 | key in (obj or {}).keys() # SIM118 -35 | +35 | 36 | (key) in (obj or {}).keys() # SIM118 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 -37 | +37 | 38 | from typing import KeysView | = help: Remove `.keys()` @@ -361,7 +360,7 @@ SIM118.py:52:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` 51 | (key in obj.keys())and foo 52 | key in (obj.keys())and foo | ^^^^^^^^^^^^^^^^^^^ SIM118 -53 | +53 | 54 | # Regression test for: https://github.com/astral-sh/ruff/issues/7200 | = help: Remove `.keys()` diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM208_SIM208.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM208_SIM208.py.snap index df03a92a725ae..39455218cfba0 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM208_SIM208.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM208_SIM208.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM208.py:1:4: SIM208 [*] Use `a` instead of `not (not a)` | @@ -20,7 +19,7 @@ SIM208.py:1:4: SIM208 [*] Use `a` instead of `not (not a)` SIM208.py:4:4: SIM208 [*] Use `a == b` instead of `not (not a == b)` | 2 | pass -3 | +3 | 4 | if not (not (a == b)): # SIM208 | ^^^^^^^^^^^^^^^^^^ SIM208 5 | pass @@ -40,10 +39,10 @@ SIM208.py:4:4: SIM208 [*] Use `a == b` instead of `not (not a == b)` SIM208.py:16:5: SIM208 [*] Use `b` instead of `not (not b)` | 14 | pass -15 | +15 | 16 | a = not not b # SIM208 | ^^^^^^^^^ SIM208 -17 | +17 | 18 | f(not not a) # SIM208 | = help: Replace with `b` @@ -61,10 +60,10 @@ SIM208.py:16:5: SIM208 [*] Use `b` instead of `not (not b)` SIM208.py:18:3: SIM208 [*] Use `a` instead of `not (not a)` | 16 | a = not not b # SIM208 -17 | +17 | 18 | f(not not a) # SIM208 | ^^^^^^^^^ SIM208 -19 | +19 | 20 | if 1 + (not (not a)): # SIM208 | = help: Replace with `a` @@ -82,7 +81,7 @@ SIM208.py:18:3: SIM208 [*] Use `a` instead of `not (not a)` SIM208.py:20:9: SIM208 [*] Use `a` instead of `not (not a)` | 18 | f(not not a) # SIM208 -19 | +19 | 20 | if 1 + (not (not a)): # SIM208 | ^^^^^^^^^^^ SIM208 21 | pass diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM210_SIM210.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM210_SIM210.py.snap index 3f510cfa800ed..3ccfac277d956 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM210_SIM210.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM210_SIM210.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM210.py:1:5: SIM210 [*] Use `bool(...)` instead of `True if ... else False` | 1 | a = True if b else False # SIM210 | ^^^^^^^^^^^^^^^^^^^^ SIM210 -2 | +2 | 3 | a = True if b != c else False # SIM210 | = help: Replace with `bool(...) @@ -21,10 +20,10 @@ SIM210.py:1:5: SIM210 [*] Use `bool(...)` instead of `True if ... else False` SIM210.py:3:5: SIM210 [*] Remove unnecessary `True if ... else False` | 1 | a = True if b else False # SIM210 -2 | +2 | 3 | a = True if b != c else False # SIM210 | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM210 -4 | +4 | 5 | a = True if b + c else False # SIM210 | = help: Remove unnecessary `True if ... else False` @@ -41,10 +40,10 @@ SIM210.py:3:5: SIM210 [*] Remove unnecessary `True if ... else False` SIM210.py:5:5: SIM210 [*] Use `bool(...)` instead of `True if ... else False` | 3 | a = True if b != c else False # SIM210 -4 | +4 | 5 | a = True if b + c else False # SIM210 | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM210 -6 | +6 | 7 | a = False if b else True # OK | = help: Replace with `bool(...) @@ -62,7 +61,7 @@ SIM210.py:5:5: SIM210 [*] Use `bool(...)` instead of `True if ... else False` SIM210.py:15:9: SIM210 Use `bool(...)` instead of `True if ... else False` | 13 | return False -14 | +14 | 15 | a = True if b else False | ^^^^^^^^^^^^^^^^^^^^ SIM210 | diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM211_SIM211.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM211_SIM211.py.snap index d929bce24b9c2..f064d0046f2b3 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM211_SIM211.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM211_SIM211.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM211.py:1:5: SIM211 [*] Use `not ...` instead of `False if ... else True` | 1 | a = False if b else True # SIM211 | ^^^^^^^^^^^^^^^^^^^^ SIM211 -2 | +2 | 3 | a = False if b != c else True # SIM211 | = help: Replace with `not ...` @@ -21,10 +20,10 @@ SIM211.py:1:5: SIM211 [*] Use `not ...` instead of `False if ... else True` SIM211.py:3:5: SIM211 [*] Use `not ...` instead of `False if ... else True` | 1 | a = False if b else True # SIM211 -2 | +2 | 3 | a = False if b != c else True # SIM211 | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM211 -4 | +4 | 5 | a = False if b + c else True # SIM211 | = help: Replace with `not ...` @@ -41,10 +40,10 @@ SIM211.py:3:5: SIM211 [*] Use `not ...` instead of `False if ... else True` SIM211.py:5:5: SIM211 [*] Use `not ...` instead of `False if ... else True` | 3 | a = False if b != c else True # SIM211 -4 | +4 | 5 | a = False if b + c else True # SIM211 | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM211 -6 | +6 | 7 | a = True if b else False # OK | = help: Replace with `not ...` diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM212_SIM212.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM212_SIM212.py.snap index e921f9fc834ab..8696c8e69df49 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM212_SIM212.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM212_SIM212.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM212.py:1:5: SIM212 [*] Use `a if a else b` instead of `b if not a else a` | 1 | c = b if not a else a # SIM212 | ^^^^^^^^^^^^^^^^^ SIM212 -2 | +2 | 3 | c = b + c if not a else a # SIM212 | = help: Replace with `a if a else b` @@ -21,10 +20,10 @@ SIM212.py:1:5: SIM212 [*] Use `a if a else b` instead of `b if not a else a` SIM212.py:3:5: SIM212 [*] Use `a if a else b + c` instead of `b + c if not a else a` | 1 | c = b if not a else a # SIM212 -2 | +2 | 3 | c = b + c if not a else a # SIM212 | ^^^^^^^^^^^^^^^^^^^^^ SIM212 -4 | +4 | 5 | c = b if not x else a # OK | = help: Replace with `a if a else b + c` diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM220_SIM220.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM220_SIM220.py.snap index 631c661a8327e..a6a073846bd15 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM220_SIM220.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM220_SIM220.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM220.py:1:4: SIM220 [*] Use `False` instead of `a and not a` | @@ -20,7 +19,7 @@ SIM220.py:1:4: SIM220 [*] Use `False` instead of `a and not a` SIM220.py:4:5: SIM220 [*] Use `False` instead of `a and not a` | 2 | pass -3 | +3 | 4 | if (a and not a) and b: | ^^^^^^^^^^^ SIM220 5 | pass @@ -40,7 +39,7 @@ SIM220.py:4:5: SIM220 [*] Use `False` instead of `a and not a` SIM220.py:7:5: SIM220 [*] Use `False` instead of `a and not a` | 5 | pass -6 | +6 | 7 | if (a and not a) or b: | ^^^^^^^^^^^ SIM220 8 | pass diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM221_SIM221.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM221_SIM221.py.snap index ae2354a7c6223..d34af71f63f96 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM221_SIM221.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM221_SIM221.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM221.py:1:4: SIM221 [*] Use `True` instead of `a or not a` | @@ -20,7 +19,7 @@ SIM221.py:1:4: SIM221 [*] Use `True` instead of `a or not a` SIM221.py:4:5: SIM221 [*] Use `True` instead of `a or not a` | 2 | pass -3 | +3 | 4 | if (a or not a) or b: | ^^^^^^^^^^ SIM221 5 | pass @@ -40,7 +39,7 @@ SIM221.py:4:5: SIM221 [*] Use `True` instead of `a or not a` SIM221.py:7:5: SIM221 [*] Use `True` instead of `a or not a` | 5 | pass -6 | +6 | 7 | if (a or not a) and b: | ^^^^^^^^^^ SIM221 8 | pass diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM222_SIM222.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM222_SIM222.py.snap index bf78eede11102..f011dba942268 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM222_SIM222.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM222_SIM222.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM222.py:1:4: SIM222 [*] Use `True` instead of `... or True` | @@ -20,7 +19,7 @@ SIM222.py:1:4: SIM222 [*] Use `True` instead of `... or True` SIM222.py:4:4: SIM222 [*] Use `True` instead of `... or True` | 2 | pass -3 | +3 | 4 | if (a or b) or True: # SIM222 | ^^^^^^^^^^^^^^^^ SIM222 5 | pass @@ -40,7 +39,7 @@ SIM222.py:4:4: SIM222 [*] Use `True` instead of `... or True` SIM222.py:7:10: SIM222 [*] Use `True` instead of `... or True` | 5 | pass -6 | +6 | 7 | if a or (b or True): # SIM222 | ^^^^^^^^^ SIM222 8 | pass @@ -60,7 +59,7 @@ SIM222.py:7:10: SIM222 [*] Use `True` instead of `... or True` SIM222.py:24:16: SIM222 [*] Use `True` instead of `True or ...` | 22 | pass -23 | +23 | 24 | if a or f() or True or g() or b: # SIM222 | ^^^^^^^^^^^^^^^^ SIM222 25 | pass @@ -80,7 +79,7 @@ SIM222.py:24:16: SIM222 [*] Use `True` instead of `True or ...` SIM222.py:27:4: SIM222 [*] Use `True` instead of `True or ...` | 25 | pass -26 | +26 | 27 | if True or f() or a or g() or b: # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 28 | pass @@ -100,7 +99,7 @@ SIM222.py:27:4: SIM222 [*] Use `True` instead of `True or ...` SIM222.py:30:4: SIM222 [*] Use `True` instead of `... or True or ...` | 28 | pass -29 | +29 | 30 | if a or True or f() or b or g(): # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 31 | pass @@ -121,7 +120,7 @@ SIM222.py:47:6: SIM222 [*] Use `True` instead of `... or True` | 47 | a or "" or True # SIM222 | ^^^^^^^^^^ SIM222 -48 | +48 | 49 | a or "foo" or True or "bar" # SIM222 | = help: Replace with `True` @@ -139,10 +138,10 @@ SIM222.py:47:6: SIM222 [*] Use `True` instead of `... or True` SIM222.py:49:6: SIM222 [*] Use `"foo"` instead of `"foo" or ...` | 47 | a or "" or True # SIM222 -48 | +48 | 49 | a or "foo" or True or "bar" # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^ SIM222 -50 | +50 | 51 | a or 0 or True # SIM222 | = help: Replace with `"foo"` @@ -160,10 +159,10 @@ SIM222.py:49:6: SIM222 [*] Use `"foo"` instead of `"foo" or ...` SIM222.py:51:6: SIM222 [*] Use `True` instead of `... or True` | 49 | a or "foo" or True or "bar" # SIM222 -50 | +50 | 51 | a or 0 or True # SIM222 | ^^^^^^^^^ SIM222 -52 | +52 | 53 | a or 1 or True or 2 # SIM222 | = help: Replace with `True` @@ -181,10 +180,10 @@ SIM222.py:51:6: SIM222 [*] Use `True` instead of `... or True` SIM222.py:53:6: SIM222 [*] Use `1` instead of `1 or ...` | 51 | a or 0 or True # SIM222 -52 | +52 | 53 | a or 1 or True or 2 # SIM222 | ^^^^^^^^^^^^^^ SIM222 -54 | +54 | 55 | a or 0.0 or True # SIM222 | = help: Replace with `1` @@ -202,10 +201,10 @@ SIM222.py:53:6: SIM222 [*] Use `1` instead of `1 or ...` SIM222.py:55:6: SIM222 [*] Use `True` instead of `... or True` | 53 | a or 1 or True or 2 # SIM222 -54 | +54 | 55 | a or 0.0 or True # SIM222 | ^^^^^^^^^^^ SIM222 -56 | +56 | 57 | a or 0.1 or True or 0.2 # SIM222 | = help: Replace with `True` @@ -223,10 +222,10 @@ SIM222.py:55:6: SIM222 [*] Use `True` instead of `... or True` SIM222.py:57:6: SIM222 [*] Use `0.1` instead of `0.1 or ...` | 55 | a or 0.0 or True # SIM222 -56 | +56 | 57 | a or 0.1 or True or 0.2 # SIM222 | ^^^^^^^^^^^^^^^^^^ SIM222 -58 | +58 | 59 | a or [] or True # SIM222 | = help: Replace with `0.1` @@ -244,10 +243,10 @@ SIM222.py:57:6: SIM222 [*] Use `0.1` instead of `0.1 or ...` SIM222.py:59:6: SIM222 [*] Use `True` instead of `... or True` | 57 | a or 0.1 or True or 0.2 # SIM222 -58 | +58 | 59 | a or [] or True # SIM222 | ^^^^^^^^^^ SIM222 -60 | +60 | 61 | a or list([]) or True # SIM222 | = help: Replace with `True` @@ -265,10 +264,10 @@ SIM222.py:59:6: SIM222 [*] Use `True` instead of `... or True` SIM222.py:61:6: SIM222 [*] Use `True` instead of `... or True` | 59 | a or [] or True # SIM222 -60 | +60 | 61 | a or list([]) or True # SIM222 | ^^^^^^^^^^^^^^^^ SIM222 -62 | +62 | 63 | a or [1] or True or [2] # SIM222 | = help: Replace with `True` @@ -286,10 +285,10 @@ SIM222.py:61:6: SIM222 [*] Use `True` instead of `... or True` SIM222.py:63:6: SIM222 [*] Use `[1]` instead of `[1] or ...` | 61 | a or list([]) or True # SIM222 -62 | +62 | 63 | a or [1] or True or [2] # SIM222 | ^^^^^^^^^^^^^^^^^^ SIM222 -64 | +64 | 65 | a or list([1]) or True or list([2]) # SIM222 | = help: Replace with `[1]` @@ -307,10 +306,10 @@ SIM222.py:63:6: SIM222 [*] Use `[1]` instead of `[1] or ...` SIM222.py:65:6: SIM222 [*] Use `list([1])` instead of `list([1]) or ...` | 63 | a or [1] or True or [2] # SIM222 -64 | +64 | 65 | a or list([1]) or True or list([2]) # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -66 | +66 | 67 | a or {} or True # SIM222 | = help: Replace with `list([1])` @@ -328,10 +327,10 @@ SIM222.py:65:6: SIM222 [*] Use `list([1])` instead of `list([1]) or ...` SIM222.py:67:6: SIM222 [*] Use `True` instead of `... or True` | 65 | a or list([1]) or True or list([2]) # SIM222 -66 | +66 | 67 | a or {} or True # SIM222 | ^^^^^^^^^^ SIM222 -68 | +68 | 69 | a or dict() or True # SIM222 | = help: Replace with `True` @@ -349,10 +348,10 @@ SIM222.py:67:6: SIM222 [*] Use `True` instead of `... or True` SIM222.py:69:6: SIM222 [*] Use `True` instead of `... or True` | 67 | a or {} or True # SIM222 -68 | +68 | 69 | a or dict() or True # SIM222 | ^^^^^^^^^^^^^^ SIM222 -70 | +70 | 71 | a or {1: 1} or True or {2: 2} # SIM222 | = help: Replace with `True` @@ -370,10 +369,10 @@ SIM222.py:69:6: SIM222 [*] Use `True` instead of `... or True` SIM222.py:71:6: SIM222 [*] Use `{1: 1}` instead of `{1: 1} or ...` | 69 | a or dict() or True # SIM222 -70 | +70 | 71 | a or {1: 1} or True or {2: 2} # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -72 | +72 | 73 | a or dict({1: 1}) or True or dict({2: 2}) # SIM222 | = help: Replace with `{1: 1}` @@ -391,10 +390,10 @@ SIM222.py:71:6: SIM222 [*] Use `{1: 1}` instead of `{1: 1} or ...` SIM222.py:73:6: SIM222 [*] Use `dict({1: 1})` instead of `dict({1: 1}) or ...` | 71 | a or {1: 1} or True or {2: 2} # SIM222 -72 | +72 | 73 | a or dict({1: 1}) or True or dict({2: 2}) # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -74 | +74 | 75 | a or set() or True # SIM222 | = help: Replace with `dict({1: 1})` @@ -412,10 +411,10 @@ SIM222.py:73:6: SIM222 [*] Use `dict({1: 1})` instead of `dict({1: 1}) or ...` SIM222.py:75:6: SIM222 [*] Use `True` instead of `... or True` | 73 | a or dict({1: 1}) or True or dict({2: 2}) # SIM222 -74 | +74 | 75 | a or set() or True # SIM222 | ^^^^^^^^^^^^^ SIM222 -76 | +76 | 77 | a or set(set()) or True # SIM222 | = help: Replace with `True` @@ -433,10 +432,10 @@ SIM222.py:75:6: SIM222 [*] Use `True` instead of `... or True` SIM222.py:77:6: SIM222 [*] Use `True` instead of `... or True` | 75 | a or set() or True # SIM222 -76 | +76 | 77 | a or set(set()) or True # SIM222 | ^^^^^^^^^^^^^^^^^^ SIM222 -78 | +78 | 79 | a or {1} or True or {2} # SIM222 | = help: Replace with `True` @@ -454,10 +453,10 @@ SIM222.py:77:6: SIM222 [*] Use `True` instead of `... or True` SIM222.py:79:6: SIM222 [*] Use `{1}` instead of `{1} or ...` | 77 | a or set(set()) or True # SIM222 -78 | +78 | 79 | a or {1} or True or {2} # SIM222 | ^^^^^^^^^^^^^^^^^^ SIM222 -80 | +80 | 81 | a or set({1}) or True or set({2}) # SIM222 | = help: Replace with `{1}` @@ -475,10 +474,10 @@ SIM222.py:79:6: SIM222 [*] Use `{1}` instead of `{1} or ...` SIM222.py:81:6: SIM222 [*] Use `set({1})` instead of `set({1}) or ...` | 79 | a or {1} or True or {2} # SIM222 -80 | +80 | 81 | a or set({1}) or True or set({2}) # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -82 | +82 | 83 | a or () or True # SIM222 | = help: Replace with `set({1})` @@ -496,10 +495,10 @@ SIM222.py:81:6: SIM222 [*] Use `set({1})` instead of `set({1}) or ...` SIM222.py:83:6: SIM222 [*] Use `True` instead of `... or True` | 81 | a or set({1}) or True or set({2}) # SIM222 -82 | +82 | 83 | a or () or True # SIM222 | ^^^^^^^^^^ SIM222 -84 | +84 | 85 | a or tuple(()) or True # SIM222 | = help: Replace with `True` @@ -517,10 +516,10 @@ SIM222.py:83:6: SIM222 [*] Use `True` instead of `... or True` SIM222.py:85:6: SIM222 [*] Use `True` instead of `... or True` | 83 | a or () or True # SIM222 -84 | +84 | 85 | a or tuple(()) or True # SIM222 | ^^^^^^^^^^^^^^^^^ SIM222 -86 | +86 | 87 | a or (1,) or True or (2,) # SIM222 | = help: Replace with `True` @@ -538,10 +537,10 @@ SIM222.py:85:6: SIM222 [*] Use `True` instead of `... or True` SIM222.py:87:6: SIM222 [*] Use `(1,)` instead of `(1,) or ...` | 85 | a or tuple(()) or True # SIM222 -86 | +86 | 87 | a or (1,) or True or (2,) # SIM222 | ^^^^^^^^^^^^^^^^^^^^ SIM222 -88 | +88 | 89 | a or tuple((1,)) or True or tuple((2,)) # SIM222 | = help: Replace with `(1,)` @@ -559,10 +558,10 @@ SIM222.py:87:6: SIM222 [*] Use `(1,)` instead of `(1,) or ...` SIM222.py:89:6: SIM222 [*] Use `tuple((1,))` instead of `tuple((1,)) or ...` | 87 | a or (1,) or True or (2,) # SIM222 -88 | +88 | 89 | a or tuple((1,)) or True or tuple((2,)) # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -90 | +90 | 91 | a or frozenset() or True # SIM222 | = help: Replace with `tuple((1,))` @@ -580,10 +579,10 @@ SIM222.py:89:6: SIM222 [*] Use `tuple((1,))` instead of `tuple((1,)) or ...` SIM222.py:91:6: SIM222 [*] Use `True` instead of `... or True` | 89 | a or tuple((1,)) or True or tuple((2,)) # SIM222 -90 | +90 | 91 | a or frozenset() or True # SIM222 | ^^^^^^^^^^^^^^^^^^^ SIM222 -92 | +92 | 93 | a or frozenset(frozenset()) or True # SIM222 | = help: Replace with `True` @@ -601,10 +600,10 @@ SIM222.py:91:6: SIM222 [*] Use `True` instead of `... or True` SIM222.py:93:6: SIM222 [*] Use `True` instead of `... or True` | 91 | a or frozenset() or True # SIM222 -92 | +92 | 93 | a or frozenset(frozenset()) or True # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -94 | +94 | 95 | a or frozenset({1}) or True or frozenset({2}) # SIM222 | = help: Replace with `True` @@ -622,10 +621,10 @@ SIM222.py:93:6: SIM222 [*] Use `True` instead of `... or True` SIM222.py:95:6: SIM222 [*] Use `frozenset({1})` instead of `frozenset({1}) or ...` | 93 | a or frozenset(frozenset()) or True # SIM222 -94 | +94 | 95 | a or frozenset({1}) or True or frozenset({2}) # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -96 | +96 | 97 | a or frozenset(frozenset({1})) or True or frozenset(frozenset({2})) # SIM222 | = help: Replace with `frozenset({1})` @@ -643,7 +642,7 @@ SIM222.py:95:6: SIM222 [*] Use `frozenset({1})` instead of `frozenset({1}) or .. SIM222.py:97:6: SIM222 [*] Use `frozenset(frozenset({1}))` instead of `frozenset(frozenset({1})) or ...` | 95 | a or frozenset({1}) or True or frozenset({2}) # SIM222 -96 | +96 | 97 | a or frozenset(frozenset({1})) or True or frozenset(frozenset({2})) # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 | @@ -662,10 +661,10 @@ SIM222.py:97:6: SIM222 [*] Use `frozenset(frozenset({1}))` instead of `frozenset SIM222.py:102:6: SIM222 [*] Use `True` instead of `... or True or ...` | 100 | # Inside test `a` is simplified. -101 | +101 | 102 | bool(a or [1] or True or [2]) # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -103 | +103 | 104 | assert a or [1] or True or [2] # SIM222 | = help: Replace with `True` @@ -683,10 +682,10 @@ SIM222.py:102:6: SIM222 [*] Use `True` instead of `... or True or ...` SIM222.py:104:8: SIM222 [*] Use `True` instead of `... or True or ...` | 102 | bool(a or [1] or True or [2]) # SIM222 -103 | +103 | 104 | assert a or [1] or True or [2] # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -105 | +105 | 106 | if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 | = help: Replace with `True` @@ -704,7 +703,7 @@ SIM222.py:104:8: SIM222 [*] Use `True` instead of `... or True or ...` SIM222.py:106:5: SIM222 [*] Use `True` instead of `... or True or ...` | 104 | assert a or [1] or True or [2] # SIM222 -105 | +105 | 106 | if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 107 | pass @@ -724,7 +723,7 @@ SIM222.py:106:5: SIM222 [*] Use `True` instead of `... or True or ...` SIM222.py:106:35: SIM222 [*] Use `True` instead of `... or True or ...` | 104 | assert a or [1] or True or [2] # SIM222 -105 | +105 | 106 | if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 107 | pass @@ -744,10 +743,10 @@ SIM222.py:106:35: SIM222 [*] Use `True` instead of `... or True or ...` SIM222.py:109:6: SIM222 [*] Use `True` instead of `... or True or ...` | 107 | pass -108 | +108 | 109 | 0 if a or [1] or True or [2] else 1 # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -110 | +110 | 111 | while a or [1] or True or [2]: # SIM222 | = help: Replace with `True` @@ -765,7 +764,7 @@ SIM222.py:109:6: SIM222 [*] Use `True` instead of `... or True or ...` SIM222.py:111:7: SIM222 [*] Use `True` instead of `... or True or ...` | 109 | 0 if a or [1] or True or [2] else 1 # SIM222 -110 | +110 | 111 | while a or [1] or True or [2]: # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 112 | pass @@ -949,10 +948,10 @@ SIM222.py:143:8: SIM222 [*] Use `True` instead of `... or True or ...` SIM222.py:148:6: SIM222 [*] Use `[1]` instead of `[1] or ...` | 146 | # Outside test `a` is not simplified. -147 | +147 | 148 | a or [1] or True or [2] # SIM222 | ^^^^^^^^^^^^^^^^^^ SIM222 -149 | +149 | 150 | if (a or [1] or True or [2]) == (a or [1]): # SIM222 | = help: Replace with `[1]` @@ -970,7 +969,7 @@ SIM222.py:148:6: SIM222 [*] Use `[1]` instead of `[1] or ...` SIM222.py:150:10: SIM222 [*] Use `[1]` instead of `[1] or ...` | 148 | a or [1] or True or [2] # SIM222 -149 | +149 | 150 | if (a or [1] or True or [2]) == (a or [1]): # SIM222 | ^^^^^^^^^^^^^^^^^^ SIM222 151 | pass @@ -990,7 +989,7 @@ SIM222.py:150:10: SIM222 [*] Use `[1]` instead of `[1] or ...` SIM222.py:153:11: SIM222 [*] Use `[1]` instead of `[1] or ...` | 151 | pass -152 | +152 | 153 | if f(a or [1] or True or [2]): # SIM222 | ^^^^^^^^^^^^^^^^^^ SIM222 154 | pass diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM223_SIM223.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM223_SIM223.py.snap index 7c83ffeb3c0de..5848727101ff0 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM223_SIM223.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM223_SIM223.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM223.py:1:4: SIM223 [*] Use `False` instead of `... and False` | @@ -20,7 +19,7 @@ SIM223.py:1:4: SIM223 [*] Use `False` instead of `... and False` SIM223.py:4:4: SIM223 [*] Use `False` instead of `... and False` | 2 | pass -3 | +3 | 4 | if (a or b) and False: # SIM223 | ^^^^^^^^^^^^^^^^^^ SIM223 5 | pass @@ -40,7 +39,7 @@ SIM223.py:4:4: SIM223 [*] Use `False` instead of `... and False` SIM223.py:7:10: SIM223 [*] Use `False` instead of `... and False` | 5 | pass -6 | +6 | 7 | if a or (b and False): # SIM223 | ^^^^^^^^^^^ SIM223 8 | pass @@ -60,7 +59,7 @@ SIM223.py:7:10: SIM223 [*] Use `False` instead of `... and False` SIM223.py:19:18: SIM223 [*] Use `False` instead of `False and ...` | 17 | pass -18 | +18 | 19 | if a and f() and False and g() and b: # SIM223 | ^^^^^^^^^^^^^^^^^^^ SIM223 20 | pass @@ -80,7 +79,7 @@ SIM223.py:19:18: SIM223 [*] Use `False` instead of `False and ...` SIM223.py:22:4: SIM223 [*] Use `False` instead of `False and ...` | 20 | pass -21 | +21 | 22 | if False and f() and a and g() and b: # SIM223 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 23 | pass @@ -100,7 +99,7 @@ SIM223.py:22:4: SIM223 [*] Use `False` instead of `False and ...` SIM223.py:25:4: SIM223 [*] Use `False` instead of `... and False and ...` | 23 | pass -24 | +24 | 25 | if a and False and f() and b and g(): # SIM223 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 26 | pass @@ -121,7 +120,7 @@ SIM223.py:42:7: SIM223 [*] Use `""` instead of `"" and ...` | 42 | a and "" and False # SIM223 | ^^^^^^^^^^^^ SIM223 -43 | +43 | 44 | a and "foo" and False and "bar" # SIM223 | = help: Replace with `""` @@ -139,10 +138,10 @@ SIM223.py:42:7: SIM223 [*] Use `""` instead of `"" and ...` SIM223.py:44:7: SIM223 [*] Use `False` instead of `... and False and ...` | 42 | a and "" and False # SIM223 -43 | +43 | 44 | a and "foo" and False and "bar" # SIM223 | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -45 | +45 | 46 | a and 0 and False # SIM223 | = help: Replace with `False` @@ -160,10 +159,10 @@ SIM223.py:44:7: SIM223 [*] Use `False` instead of `... and False and ...` SIM223.py:46:7: SIM223 [*] Use `0` instead of `0 and ...` | 44 | a and "foo" and False and "bar" # SIM223 -45 | +45 | 46 | a and 0 and False # SIM223 | ^^^^^^^^^^^ SIM223 -47 | +47 | 48 | a and 1 and False and 2 # SIM223 | = help: Replace with `0` @@ -181,10 +180,10 @@ SIM223.py:46:7: SIM223 [*] Use `0` instead of `0 and ...` SIM223.py:48:7: SIM223 [*] Use `False` instead of `... and False and ...` | 46 | a and 0 and False # SIM223 -47 | +47 | 48 | a and 1 and False and 2 # SIM223 | ^^^^^^^^^^^^^^^^^ SIM223 -49 | +49 | 50 | a and 0.0 and False # SIM223 | = help: Replace with `False` @@ -202,10 +201,10 @@ SIM223.py:48:7: SIM223 [*] Use `False` instead of `... and False and ...` SIM223.py:50:7: SIM223 [*] Use `0.0` instead of `0.0 and ...` | 48 | a and 1 and False and 2 # SIM223 -49 | +49 | 50 | a and 0.0 and False # SIM223 | ^^^^^^^^^^^^^ SIM223 -51 | +51 | 52 | a and 0.1 and False and 0.2 # SIM223 | = help: Replace with `0.0` @@ -223,10 +222,10 @@ SIM223.py:50:7: SIM223 [*] Use `0.0` instead of `0.0 and ...` SIM223.py:52:7: SIM223 [*] Use `False` instead of `... and False and ...` | 50 | a and 0.0 and False # SIM223 -51 | +51 | 52 | a and 0.1 and False and 0.2 # SIM223 | ^^^^^^^^^^^^^^^^^^^^^ SIM223 -53 | +53 | 54 | a and [] and False # SIM223 | = help: Replace with `False` @@ -244,10 +243,10 @@ SIM223.py:52:7: SIM223 [*] Use `False` instead of `... and False and ...` SIM223.py:54:7: SIM223 [*] Use `[]` instead of `[] and ...` | 52 | a and 0.1 and False and 0.2 # SIM223 -53 | +53 | 54 | a and [] and False # SIM223 | ^^^^^^^^^^^^ SIM223 -55 | +55 | 56 | a and list([]) and False # SIM223 | = help: Replace with `[]` @@ -265,10 +264,10 @@ SIM223.py:54:7: SIM223 [*] Use `[]` instead of `[] and ...` SIM223.py:56:7: SIM223 [*] Use `list([])` instead of `list([]) and ...` | 54 | a and [] and False # SIM223 -55 | +55 | 56 | a and list([]) and False # SIM223 | ^^^^^^^^^^^^^^^^^^ SIM223 -57 | +57 | 58 | a and [1] and False and [2] # SIM223 | = help: Replace with `list([])` @@ -286,10 +285,10 @@ SIM223.py:56:7: SIM223 [*] Use `list([])` instead of `list([]) and ...` SIM223.py:58:7: SIM223 [*] Use `False` instead of `... and False and ...` | 56 | a and list([]) and False # SIM223 -57 | +57 | 58 | a and [1] and False and [2] # SIM223 | ^^^^^^^^^^^^^^^^^^^^^ SIM223 -59 | +59 | 60 | a and list([1]) and False and list([2]) # SIM223 | = help: Replace with `False` @@ -307,10 +306,10 @@ SIM223.py:58:7: SIM223 [*] Use `False` instead of `... and False and ...` SIM223.py:60:7: SIM223 [*] Use `False` instead of `... and False and ...` | 58 | a and [1] and False and [2] # SIM223 -59 | +59 | 60 | a and list([1]) and False and list([2]) # SIM223 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -61 | +61 | 62 | a and {} and False # SIM223 | = help: Replace with `False` @@ -328,10 +327,10 @@ SIM223.py:60:7: SIM223 [*] Use `False` instead of `... and False and ...` SIM223.py:62:7: SIM223 [*] Use `{}` instead of `{} and ...` | 60 | a and list([1]) and False and list([2]) # SIM223 -61 | +61 | 62 | a and {} and False # SIM223 | ^^^^^^^^^^^^ SIM223 -63 | +63 | 64 | a and dict() and False # SIM223 | = help: Replace with `{}` @@ -349,10 +348,10 @@ SIM223.py:62:7: SIM223 [*] Use `{}` instead of `{} and ...` SIM223.py:64:7: SIM223 [*] Use `dict()` instead of `dict() and ...` | 62 | a and {} and False # SIM223 -63 | +63 | 64 | a and dict() and False # SIM223 | ^^^^^^^^^^^^^^^^ SIM223 -65 | +65 | 66 | a and {1: 1} and False and {2: 2} # SIM223 | = help: Replace with `dict()` @@ -370,10 +369,10 @@ SIM223.py:64:7: SIM223 [*] Use `dict()` instead of `dict() and ...` SIM223.py:66:7: SIM223 [*] Use `False` instead of `... and False and ...` | 64 | a and dict() and False # SIM223 -65 | +65 | 66 | a and {1: 1} and False and {2: 2} # SIM223 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -67 | +67 | 68 | a and dict({1: 1}) and False and dict({2: 2}) # SIM223 | = help: Replace with `False` @@ -391,10 +390,10 @@ SIM223.py:66:7: SIM223 [*] Use `False` instead of `... and False and ...` SIM223.py:68:7: SIM223 [*] Use `False` instead of `... and False and ...` | 66 | a and {1: 1} and False and {2: 2} # SIM223 -67 | +67 | 68 | a and dict({1: 1}) and False and dict({2: 2}) # SIM223 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -69 | +69 | 70 | a and set() and False # SIM223 | = help: Replace with `False` @@ -412,10 +411,10 @@ SIM223.py:68:7: SIM223 [*] Use `False` instead of `... and False and ...` SIM223.py:70:7: SIM223 [*] Use `set()` instead of `set() and ...` | 68 | a and dict({1: 1}) and False and dict({2: 2}) # SIM223 -69 | +69 | 70 | a and set() and False # SIM223 | ^^^^^^^^^^^^^^^ SIM223 -71 | +71 | 72 | a and set(set()) and False # SIM223 | = help: Replace with `set()` @@ -433,10 +432,10 @@ SIM223.py:70:7: SIM223 [*] Use `set()` instead of `set() and ...` SIM223.py:72:7: SIM223 [*] Use `set(set())` instead of `set(set()) and ...` | 70 | a and set() and False # SIM223 -71 | +71 | 72 | a and set(set()) and False # SIM223 | ^^^^^^^^^^^^^^^^^^^^ SIM223 -73 | +73 | 74 | a and {1} and False and {2} # SIM223 | = help: Replace with `set(set())` @@ -454,10 +453,10 @@ SIM223.py:72:7: SIM223 [*] Use `set(set())` instead of `set(set()) and ...` SIM223.py:74:7: SIM223 [*] Use `False` instead of `... and False and ...` | 72 | a and set(set()) and False # SIM223 -73 | +73 | 74 | a and {1} and False and {2} # SIM223 | ^^^^^^^^^^^^^^^^^^^^^ SIM223 -75 | +75 | 76 | a and set({1}) and False and set({2}) # SIM223 | = help: Replace with `False` @@ -475,10 +474,10 @@ SIM223.py:74:7: SIM223 [*] Use `False` instead of `... and False and ...` SIM223.py:76:7: SIM223 [*] Use `False` instead of `... and False and ...` | 74 | a and {1} and False and {2} # SIM223 -75 | +75 | 76 | a and set({1}) and False and set({2}) # SIM223 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -77 | +77 | 78 | a and () and False # SIM222 | = help: Replace with `False` @@ -496,10 +495,10 @@ SIM223.py:76:7: SIM223 [*] Use `False` instead of `... and False and ...` SIM223.py:78:7: SIM223 [*] Use `()` instead of `() and ...` | 76 | a and set({1}) and False and set({2}) # SIM223 -77 | +77 | 78 | a and () and False # SIM222 | ^^^^^^^^^^^^ SIM223 -79 | +79 | 80 | a and tuple(()) and False # SIM222 | = help: Replace with `()` @@ -517,10 +516,10 @@ SIM223.py:78:7: SIM223 [*] Use `()` instead of `() and ...` SIM223.py:80:7: SIM223 [*] Use `tuple(())` instead of `tuple(()) and ...` | 78 | a and () and False # SIM222 -79 | +79 | 80 | a and tuple(()) and False # SIM222 | ^^^^^^^^^^^^^^^^^^^ SIM223 -81 | +81 | 82 | a and (1,) and False and (2,) # SIM222 | = help: Replace with `tuple(())` @@ -538,10 +537,10 @@ SIM223.py:80:7: SIM223 [*] Use `tuple(())` instead of `tuple(()) and ...` SIM223.py:82:7: SIM223 [*] Use `False` instead of `... and False and ...` | 80 | a and tuple(()) and False # SIM222 -81 | +81 | 82 | a and (1,) and False and (2,) # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -83 | +83 | 84 | a and tuple((1,)) and False and tuple((2,)) # SIM222 | = help: Replace with `False` @@ -559,10 +558,10 @@ SIM223.py:82:7: SIM223 [*] Use `False` instead of `... and False and ...` SIM223.py:84:7: SIM223 [*] Use `False` instead of `... and False and ...` | 82 | a and (1,) and False and (2,) # SIM222 -83 | +83 | 84 | a and tuple((1,)) and False and tuple((2,)) # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -85 | +85 | 86 | a and frozenset() and False # SIM222 | = help: Replace with `False` @@ -580,10 +579,10 @@ SIM223.py:84:7: SIM223 [*] Use `False` instead of `... and False and ...` SIM223.py:86:7: SIM223 [*] Use `frozenset()` instead of `frozenset() and ...` | 84 | a and tuple((1,)) and False and tuple((2,)) # SIM222 -85 | +85 | 86 | a and frozenset() and False # SIM222 | ^^^^^^^^^^^^^^^^^^^^^ SIM223 -87 | +87 | 88 | a and frozenset(frozenset()) and False # SIM222 | = help: Replace with `frozenset()` @@ -601,10 +600,10 @@ SIM223.py:86:7: SIM223 [*] Use `frozenset()` instead of `frozenset() and ...` SIM223.py:88:7: SIM223 [*] Use `frozenset(frozenset())` instead of `frozenset(frozenset()) and ...` | 86 | a and frozenset() and False # SIM222 -87 | +87 | 88 | a and frozenset(frozenset()) and False # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -89 | +89 | 90 | a and frozenset({1}) and False and frozenset({2}) # SIM222 | = help: Replace with `frozenset(frozenset())` @@ -622,10 +621,10 @@ SIM223.py:88:7: SIM223 [*] Use `frozenset(frozenset())` instead of `frozenset(fr SIM223.py:90:7: SIM223 [*] Use `False` instead of `... and False and ...` | 88 | a and frozenset(frozenset()) and False # SIM222 -89 | +89 | 90 | a and frozenset({1}) and False and frozenset({2}) # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -91 | +91 | 92 | a and frozenset(frozenset({1})) and False and frozenset(frozenset({2})) # SIM222 | = help: Replace with `False` @@ -643,7 +642,7 @@ SIM223.py:90:7: SIM223 [*] Use `False` instead of `... and False and ...` SIM223.py:92:7: SIM223 [*] Use `False` instead of `... and False and ...` | 90 | a and frozenset({1}) and False and frozenset({2}) # SIM222 -91 | +91 | 92 | a and frozenset(frozenset({1})) and False and frozenset(frozenset({2})) # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 | @@ -662,10 +661,10 @@ SIM223.py:92:7: SIM223 [*] Use `False` instead of `... and False and ...` SIM223.py:97:6: SIM223 [*] Use `False` instead of `... and False and ...` | 95 | # Inside test `a` is simplified. -96 | +96 | 97 | bool(a and [] and False and []) # SIM223 | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -98 | +98 | 99 | assert a and [] and False and [] # SIM223 | = help: Replace with `False` @@ -683,10 +682,10 @@ SIM223.py:97:6: SIM223 [*] Use `False` instead of `... and False and ...` SIM223.py:99:8: SIM223 [*] Use `False` instead of `... and False and ...` | 97 | bool(a and [] and False and []) # SIM223 - 98 | + 98 | 99 | assert a and [] and False and [] # SIM223 | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -100 | +100 | 101 | if (a and [] and False and []) or (a and [] and False and []): # SIM223 | = help: Replace with `False` @@ -704,7 +703,7 @@ SIM223.py:99:8: SIM223 [*] Use `False` instead of `... and False and ...` SIM223.py:101:5: SIM223 [*] Use `False` instead of `... and False and ...` | 99 | assert a and [] and False and [] # SIM223 -100 | +100 | 101 | if (a and [] and False and []) or (a and [] and False and []): # SIM223 | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 102 | pass @@ -724,7 +723,7 @@ SIM223.py:101:5: SIM223 [*] Use `False` instead of `... and False and ...` SIM223.py:101:36: SIM223 [*] Use `False` instead of `... and False and ...` | 99 | assert a and [] and False and [] # SIM223 -100 | +100 | 101 | if (a and [] and False and []) or (a and [] and False and []): # SIM223 | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 102 | pass @@ -744,10 +743,10 @@ SIM223.py:101:36: SIM223 [*] Use `False` instead of `... and False and ...` SIM223.py:104:6: SIM223 [*] Use `False` instead of `... and False and ...` | 102 | pass -103 | +103 | 104 | 0 if a and [] and False and [] else 1 # SIM222 | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -105 | +105 | 106 | while a and [] and False and []: # SIM223 | = help: Replace with `False` @@ -765,7 +764,7 @@ SIM223.py:104:6: SIM223 [*] Use `False` instead of `... and False and ...` SIM223.py:106:7: SIM223 [*] Use `False` instead of `... and False and ...` | 104 | 0 if a and [] and False and [] else 1 # SIM222 -105 | +105 | 106 | while a and [] and False and []: # SIM223 | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 107 | pass @@ -949,10 +948,10 @@ SIM223.py:138:8: SIM223 [*] Use `False` instead of `... and False and ...` SIM223.py:143:7: SIM223 [*] Use `[]` instead of `[] and ...` | 141 | # Outside test `a` is not simplified. -142 | +142 | 143 | a and [] and False and [] # SIM223 | ^^^^^^^^^^^^^^^^^^^ SIM223 -144 | +144 | 145 | if (a and [] and False and []) == (a and []): # SIM223 | = help: Replace with `[]` @@ -970,7 +969,7 @@ SIM223.py:143:7: SIM223 [*] Use `[]` instead of `[] and ...` SIM223.py:145:11: SIM223 [*] Use `[]` instead of `[] and ...` | 143 | a and [] and False and [] # SIM223 -144 | +144 | 145 | if (a and [] and False and []) == (a and []): # SIM223 | ^^^^^^^^^^^^^^^^^^^ SIM223 146 | pass @@ -990,7 +989,7 @@ SIM223.py:145:11: SIM223 [*] Use `[]` instead of `[] and ...` SIM223.py:148:12: SIM223 [*] Use `[]` instead of `[] and ...` | 146 | pass -147 | +147 | 148 | if f(a and [] and False and []): # SIM223 | ^^^^^^^^^^^^^^^^^^^ SIM223 149 | pass diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM300_SIM300.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM300_SIM300.py.snap index 677e4563ded7f..47826242246c9 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM300_SIM300.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM300_SIM300.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM300.py:2:1: SIM300 [*] Yoda condition detected | @@ -318,7 +317,7 @@ SIM300.py:17:1: SIM300 [*] Yoda condition detected 16 | B or(B)2<>3<4'.split('<>') | ^^^^^^^^^^^^^^^^^^^^^^^ SIM905 -31 | +31 | 32 | " a*a a*a a ".split("*", -1) # [' a', 'a a', 'a a '] | = help: Replace with list literal @@ -349,7 +348,7 @@ SIM905.py:30:1: SIM905 [*] Consider using a list literal instead of `str.split` SIM905.py:32:1: SIM905 [*] Consider using a list literal instead of `str.split` | 30 | '1<>2<>3<4'.split('<>') -31 | +31 | 32 | " a*a a*a a ".split("*", -1) # [' a', 'a a', 'a a '] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 33 | "".split() # [] @@ -536,7 +535,7 @@ SIM905.py:46:2: SIM905 [*] Consider using a list literal instead of `str.split` SIM905.py:53:1: SIM905 [*] Consider using a list literal instead of `str.split` | 51 | ) # ['a', 'b', 'c'] -52 | +52 | 53 | / "hello "\ 54 | | "world".split() | |___________________^ SIM905 @@ -748,7 +747,7 @@ SIM905.py:67:1: SIM905 [*] Consider using a list literal instead of `str.split` 66 | r"\n " "\n".split() # ['\\n'] 67 | "a " r"\n".split() # ['a', '\\n'] | ^^^^^^^^^^^^^^^^^^ SIM905 -68 | +68 | 69 | "a,b,c".split(',', maxsplit=0) # ['a,b,c'] | = help: Replace with list literal @@ -766,7 +765,7 @@ SIM905.py:67:1: SIM905 [*] Consider using a list literal instead of `str.split` SIM905.py:69:1: SIM905 [*] Consider using a list literal instead of `str.split` | 67 | "a " r"\n".split() # ['a', '\\n'] -68 | +68 | 69 | "a,b,c".split(',', maxsplit=0) # ['a,b,c'] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 70 | "a,b,c".split(',', maxsplit=-1) # ['a', 'b', 'c'] @@ -830,7 +829,7 @@ SIM905.py:72:1: SIM905 [*] Consider using a list literal instead of `str.split` 71 | "a,b,c".split(',', maxsplit=-2) # ['a', 'b', 'c'] 72 | "a,b,c".split(',', maxsplit=-0) # ['a,b,c'] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 -73 | +73 | 74 | # negatives | = help: Replace with list literal diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM910_SIM910.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM910_SIM910.py.snap index c43d1e140beeb..262e131eecd44 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM910_SIM910.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM910_SIM910.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM910.py:2:1: SIM910 [*] Use `{}.get(key)` instead of `{}.get(key, None)` | 1 | # SIM910 2 | {}.get(key, None) | ^^^^^^^^^^^^^^^^^ SIM910 -3 | +3 | 4 | # SIM910 | = help: Replace `{}.get(key, None)` with `{}.get(key)` @@ -25,7 +24,7 @@ SIM910.py:5:1: SIM910 [*] Use `{}.get("key")` instead of `{}.get("key", None)` 4 | # SIM910 5 | {}.get("key", None) | ^^^^^^^^^^^^^^^^^^^ SIM910 -6 | +6 | 7 | # OK | = help: Replace `{}.get("key", None)` with `{}.get("key")` @@ -64,7 +63,7 @@ SIM910.py:24:5: SIM910 [*] Use `{}.get(key)` instead of `{}.get(key, None)` 23 | # SIM910 24 | a = {}.get(key, None) | ^^^^^^^^^^^^^^^^^ SIM910 -25 | +25 | 26 | # SIM910 | = help: Replace `{}.get(key, None)` with `{}.get(key)` @@ -84,7 +83,7 @@ SIM910.py:27:1: SIM910 [*] Use `({}).get(key)` instead of `({}).get(key, None)` 26 | # SIM910 27 | ({}).get(key, None) | ^^^^^^^^^^^^^^^^^^^ SIM910 -28 | +28 | 29 | # SIM910 | = help: Replace `({}).get(key, None)` with `({}).get(key)` @@ -105,7 +104,7 @@ SIM910.py:31:7: SIM910 [*] Use `ages.get("Cat")` instead of `ages.get("Cat", Non 30 | ages = {"Tom": 23, "Maria": 23, "Dog": 11} 31 | age = ages.get("Cat", None) | ^^^^^^^^^^^^^^^^^^^^^ SIM910 -32 | +32 | 33 | # OK | = help: Replace `ages.get("Cat", None)` with `ages.get("Cat")` @@ -126,7 +125,7 @@ SIM910.py:39:9: SIM910 [*] Use `kwargs.get('a')` instead of `kwargs.get('a', Non 38 | def foo(**kwargs): 39 | a = kwargs.get('a', None) | ^^^^^^^^^^^^^^^^^^^^^ SIM910 -40 | +40 | 41 | # SIM910 | = help: Replace `kwargs.get('a', None)` with `kwargs.get('a')` @@ -147,7 +146,7 @@ SIM910.py:43:9: SIM910 [*] Use `some_dict.get('a')` instead of `some_dict.get('a 42 | def foo(some_dict: dict): 43 | a = some_dict.get('a', None) | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM910 -44 | +44 | 45 | # OK | = help: Replace `some_dict.get('a', None)` with `some_dict.get('a')` diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM108_SIM108.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM108_SIM108.py.snap index e94d188dd1133..723cf6fa66768 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM108_SIM108.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM108_SIM108.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM108.py:2:1: SIM108 [*] Use ternary operator `b = c if a else d` instead of `if`-`else`-block | @@ -10,7 +9,7 @@ SIM108.py:2:1: SIM108 [*] Use ternary operator `b = c if a else d` instead of `i 4 | | else: 5 | | b = d | |_________^ SIM108 -6 | +6 | 7 | # OK | = help: Replace `if`-`else`-block with `b = c if a else d` @@ -30,8 +29,7 @@ SIM108.py:30:5: SIM108 [*] Use ternary operator `b = 1 if a else 2` instead of ` | 28 | pass 29 | else: -30 | if a: - | _____^ +30 | / if a: 31 | | b = 1 32 | | else: 33 | | b = 2 @@ -129,7 +127,7 @@ SIM108.py:141:1: SIM108 [*] Use binary operator `z = cond or other_cond` instead 143 | | else: 144 | | z = other_cond | |__________________^ SIM108 -145 | +145 | 146 | # SIM108 - should suggest | = help: Replace `if`-`else`-block with `z = cond or other_cond` @@ -156,7 +154,7 @@ SIM108.py:148:1: SIM108 [*] Use binary operator `z = cond and other_cond` instea 150 | | else: 151 | | z = other_cond | |__________________^ SIM108 -152 | +152 | 153 | # SIM108 - should suggest | = help: Replace `if`-`else`-block with `z = cond and other_cond` @@ -183,7 +181,7 @@ SIM108.py:155:1: SIM108 [*] Use binary operator `z = not cond and other_cond` in 157 | | else: 158 | | z = other_cond | |__________________^ SIM108 -159 | +159 | 160 | # SIM108 does not suggest | = help: Replace `if`-`else`-block with `z = not cond and other_cond` @@ -210,7 +208,7 @@ SIM108.py:167:1: SIM108 [*] Use ternary operator `z = 1 if True else other` inst 169 | | else: 170 | | z = other | |_____________^ SIM108 -171 | +171 | 172 | if False: | = help: Replace `if`-`else`-block with `z = 1 if True else other` @@ -231,13 +229,13 @@ SIM108.py:167:1: SIM108 [*] Use ternary operator `z = 1 if True else other` inst SIM108.py:177:1: SIM108 [*] Use ternary operator `z = True if 1 else other` instead of `if`-`else`-block | 175 | z = other -176 | +176 | 177 | / if 1: 178 | | z = True 179 | | else: 180 | | z = other | |_____________^ SIM108 -181 | +181 | 182 | # SIM108 does not suggest a binary option in this | = help: Replace `if`-`else`-block with `z = True if 1 else other` @@ -264,7 +262,7 @@ SIM108.py:185:1: SIM108 [*] Use ternary operator `z = foo() if foo() else other` 187 | | else: 188 | | z = other | |_____________^ SIM108 -189 | +189 | 190 | # SIM108 does not suggest a binary option in this | = help: Replace `if`-`else`-block with `z = foo() if foo() else other` diff --git a/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT001_SLOT001.py.snap b/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT001_SLOT001.py.snap index d4bc0d60355fa..d2566de0579df 100644 --- a/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT001_SLOT001.py.snap +++ b/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT001_SLOT001.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_slots/mod.rs -snapshot_kind: text --- SLOT001.py:1:7: SLOT001 Subclasses of `tuple` should define `__slots__` | @@ -26,7 +25,7 @@ SLOT001.py:16:7: SLOT001 Subclasses of `tuple` should define `__slots__` SLOT001.py:26:7: SLOT001 Subclasses of `tuple` should define `__slots__` | 24 | import builtins -25 | +25 | 26 | class AlsoBad(builtins.tuple[int, int]): # SLOT001 | ^^^^^^^ SLOT001 27 | pass diff --git a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_parent_imports_package.snap b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_parent_imports_package.snap index 58146722dac30..652c0975bc09a 100644 --- a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_parent_imports_package.snap +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_parent_imports_package.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_tidy_imports/mod.rs -snapshot_kind: text --- application.py:5:1: TID252 Prefer absolute imports over relative imports from parent modules | 3 | import attrs -4 | +4 | 5 | from ....import unknown | ^^^^^^^^^^^^^^^^^^^^^^^ TID252 6 | from ..protocol import commands, definitions, responses diff --git a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_api.snap b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_api.snap index 8f97c455d82b0..e74e8b7f3eb56 100644 --- a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_api.snap +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_api.snap @@ -1,33 +1,32 @@ --- source: crates/ruff_linter/src/rules/flake8_tidy_imports/mod.rs -snapshot_kind: text --- TID251.py:2:8: TID251 `cgi` is banned: The cgi module is deprecated. | 1 | ## Banned modules ## 2 | import cgi | ^^^ TID251 -3 | +3 | 4 | from cgi import * | TID251.py:4:1: TID251 `cgi` is banned: The cgi module is deprecated. | 2 | import cgi -3 | +3 | 4 | from cgi import * | ^^^^^^^^^^^^^^^^^ TID251 -5 | +5 | 6 | from cgi import a, b, c | TID251.py:6:1: TID251 `cgi` is banned: The cgi module is deprecated. | 4 | from cgi import * -5 | +5 | 6 | from cgi import a, b, c | ^^^^^^^^^^^^^^^^^^^^^^^ TID251 -7 | +7 | 8 | # banning a module also bans any submodules | @@ -36,37 +35,37 @@ TID251.py:9:8: TID251 `cgi` is banned: The cgi module is deprecated. 8 | # banning a module also bans any submodules 9 | import cgi.foo.bar | ^^^^^^^^^^^ TID251 -10 | +10 | 11 | from cgi.foo import bar | TID251.py:11:1: TID251 `cgi` is banned: The cgi module is deprecated. | 9 | import cgi.foo.bar -10 | +10 | 11 | from cgi.foo import bar | ^^^^^^^^^^^^^^^^^^^^^^^ TID251 -12 | +12 | 13 | from cgi.foo.bar import * | TID251.py:13:1: TID251 `cgi` is banned: The cgi module is deprecated. | 11 | from cgi.foo import bar -12 | +12 | 13 | from cgi.foo.bar import * | ^^^^^^^^^^^^^^^^^^^^^^^^^ TID251 -14 | +14 | 15 | ## Banned module members ## | TID251.py:17:20: TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. | 15 | ## Banned module members ## -16 | +16 | 17 | from typing import TypedDict | ^^^^^^^^^ TID251 -18 | +18 | 19 | import typing | @@ -75,17 +74,17 @@ TID251.py:22:1: TID251 `typing.TypedDict` is banned: Use typing_extensions.Typed 21 | # attribute access is checked 22 | typing.TypedDict | ^^^^^^^^^^^^^^^^ TID251 -23 | +23 | 24 | typing.TypedDict.anything | TID251.py:24:1: TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. | 22 | typing.TypedDict -23 | +23 | 24 | typing.TypedDict.anything | ^^^^^^^^^^^^^^^^ TID251 -25 | +25 | 26 | # function calls are checked | @@ -94,17 +93,17 @@ TID251.py:27:1: TID251 `typing.TypedDict` is banned: Use typing_extensions.Typed 26 | # function calls are checked 27 | typing.TypedDict() | ^^^^^^^^^^^^^^^^ TID251 -28 | +28 | 29 | typing.TypedDict.anything() | TID251.py:29:1: TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. | 27 | typing.TypedDict() -28 | +28 | 29 | typing.TypedDict.anything() | ^^^^^^^^^^^^^^^^ TID251 -30 | +30 | 31 | # import aliases are resolved | @@ -114,6 +113,6 @@ TID251.py:33:1: TID251 `typing.TypedDict` is banned: Use typing_extensions.Typed 32 | import typing as totally_not_typing 33 | totally_not_typing.TypedDict | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID251 -34 | +34 | 35 | # relative imports are respected | diff --git a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_api_package.snap b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_api_package.snap index fd5b8bfe8b06f..47f5e3859705c 100644 --- a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_api_package.snap +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_api_package.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_tidy_imports/mod.rs -snapshot_kind: text --- application.py:3:8: TID251 `attrs` is banned: The attrs module is deprecated. | 1 | from typing import TYPE_CHECKING, Any, ClassVar -2 | +2 | 3 | import attrs | ^^^^^ TID251 -4 | +4 | 5 | from ....import unknown | diff --git a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_module_level_imports.snap b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_module_level_imports.snap index cf8a780c15989..eb8c2d42a54d9 100644 --- a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_module_level_imports.snap +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_module_level_imports.snap @@ -1,43 +1,42 @@ --- source: crates/ruff_linter/src/rules/flake8_tidy_imports/mod.rs -snapshot_kind: text --- TID253.py:2:8: TID253 `torch` is banned at the module level | 1 | ## Banned modules ## 2 | import torch | ^^^^^ TID253 -3 | +3 | 4 | from torch import * | TID253.py:4:1: TID253 `torch` is banned at the module level | 2 | import torch -3 | +3 | 4 | from torch import * | ^^^^^^^^^^^^^^^^^^^ TID253 -5 | +5 | 6 | from tensorflow import a, b, c | TID253.py:6:1: TID253 `tensorflow` is banned at the module level | 4 | from torch import * -5 | +5 | 6 | from tensorflow import a, b, c | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID253 -7 | +7 | 8 | import torch as torch_wearing_a_trenchcoat | TID253.py:8:8: TID253 `torch` is banned at the module level | 6 | from tensorflow import a, b, c - 7 | + 7 | 8 | import torch as torch_wearing_a_trenchcoat | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID253 - 9 | + 9 | 10 | # this should count as module level | @@ -46,7 +45,7 @@ TID253.py:11:15: TID253 `tensorflow` is banned at the module level 10 | # this should count as module level 11 | x = 1; import tensorflow | ^^^^^^^^^^ TID253 -12 | +12 | 13 | # banning a module also bans any submodules | @@ -55,26 +54,26 @@ TID253.py:14:8: TID253 `torch` is banned at the module level 13 | # banning a module also bans any submodules 14 | import torch.foo.bar | ^^^^^^^^^^^^^ TID253 -15 | +15 | 16 | from tensorflow.foo import bar | TID253.py:16:1: TID253 `tensorflow` is banned at the module level | 14 | import torch.foo.bar -15 | +15 | 16 | from tensorflow.foo import bar | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID253 -17 | +17 | 18 | from torch.foo.bar import * | TID253.py:18:1: TID253 `torch` is banned at the module level | 16 | from tensorflow.foo import bar -17 | +17 | 18 | from torch.foo.bar import * | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID253 -19 | +19 | 20 | # unlike TID251, inline imports are *not* banned | diff --git a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-link_TD003.py.snap b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-link_TD003.py.snap index 1b6f46ce5cdff..c381500f7c2e9 100644 --- a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-link_TD003.py.snap +++ b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-link_TD003.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_todos/mod.rs -snapshot_kind: text --- TD003.py:15:3: TD003 Missing issue link on the line following this TODO | @@ -13,7 +12,7 @@ TD003.py:15:3: TD003 Missing issue link on the line following this TODO TD003.py:18:3: TD003 Missing issue link on the line following this TODO | 16 | # link after it -17 | +17 | 18 | # TODO: here's a TODO with no link after it | ^^^^ TD003 19 | def foo(x): @@ -23,7 +22,7 @@ TD003.py:18:3: TD003 Missing issue link on the line following this TODO TD003.py:31:3: TD003 Missing issue link on the line following this TODO | 29 | # TDO-3870 -30 | +30 | 31 | # TODO: here's a TODO without an issue link | ^^^^ TD003 32 | # TODO: followed by a new TODO with an issue link @@ -33,17 +32,17 @@ TD003.py:31:3: TD003 Missing issue link on the line following this TODO TD003.py:35:9: TD003 Missing issue link on the line following this TODO | 33 | # TDO-3870 -34 | +34 | 35 | # foo # TODO: no link! | ^^^^ TD003 -36 | +36 | 37 | # TODO: here's a TODO on the last line with no link | TD003.py:37:3: TD003 Missing issue link on the line following this TODO | 35 | # foo # TODO: no link! -36 | +36 | 37 | # TODO: here's a TODO on the last line with no link | ^^^^ TD003 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__empty-type-checking-block_TC005.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__empty-type-checking-block_TC005.py.snap index 14fc75ff7368c..137f000062e72 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__empty-type-checking-block_TC005.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__empty-type-checking-block_TC005.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- TC005.py:4:5: TC005 [*] Found empty type-checking block | @@ -24,7 +23,7 @@ TC005.py:8:5: TC005 [*] Found empty type-checking block 7 | if False: 8 | pass # TC005 | ^^^^ TC005 - 9 | + 9 | 10 | if 0: | = help: Delete empty type-checking block @@ -102,7 +101,7 @@ TC005.py:45:5: TC005 [*] Found empty type-checking block 44 | if TYPE_CHECKING: 45 | pass # TC005 | ^^^^ TC005 -46 | +46 | 47 | # https://github.com/astral-sh/ruff/issues/11368 | = help: Delete empty type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__exempt_modules.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__exempt_modules.snap index 215264924b407..86813404430be 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__exempt_modules.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__exempt_modules.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- exempt_modules.py:14:12: TC002 [*] Move third-party import `flask` into a type-checking block | 13 | def f(): 14 | import flask | ^^^^^ TC002 -15 | +15 | 16 | x: flask | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_different_types.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_different_types.snap index e8300136de4ca..2e46ea78ae82e 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_different_types.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_different_types.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- :6:8: TC003 [*] Move standard library import `os` into a type-checking block | 4 | from typing import TYPE_CHECKING -5 | +5 | 6 | import os, pandas | ^^ TC003 -7 | +7 | 8 | def f(x: os, y: pandas): | = help: Move into type-checking block @@ -29,10 +28,10 @@ snapshot_kind: text :6:12: TC002 [*] Move third-party import `pandas` into a type-checking block | 4 | from typing import TYPE_CHECKING -5 | +5 | 6 | import os, pandas | ^^^^^^ TC002 -7 | +7 | 8 | def f(x: os, y: pandas): | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_same_type.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_same_type.snap index aa2a82e116641..4b1eeaaeb92a2 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_same_type.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_same_type.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- :6:8: TC003 [*] Move standard library import `os` into a type-checking block | 4 | from typing import TYPE_CHECKING -5 | +5 | 6 | import os, sys | ^^ TC003 -7 | +7 | 8 | def f(x: os, y: sys): | = help: Move into type-checking block @@ -28,10 +27,10 @@ snapshot_kind: text :6:12: TC003 [*] Move standard library import `sys` into a type-checking block | 4 | from typing import TYPE_CHECKING -5 | +5 | 6 | import os, sys | ^^^ TC003 -7 | +7 | 8 | def f(x: os, y: sys): | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__no_typing_import.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__no_typing_import.snap index 8b3c5b1c1a5be..5b14c673f9d9a 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__no_typing_import.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__no_typing_import.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- :4:18: TC002 [*] Move third-party import `pandas` into a type-checking block | 2 | from __future__ import annotations -3 | +3 | 4 | import pandas as pd | ^^ TC002 -5 | +5 | 6 | def f(x: pd.DataFrame): | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_runtime-import-in-type-checking-block_quote.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_runtime-import-in-type-checking-block_quote.py.snap index c782c1ec08dcf..658646b7c2411 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_runtime-import-in-type-checking-block_quote.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_runtime-import-in-type-checking-block_quote.py.snap @@ -6,7 +6,7 @@ quote.py:57:28: TC004 [*] Quote references to `pandas.DataFrame`. Import is in a 56 | if TYPE_CHECKING: 57 | from pandas import DataFrame | ^^^^^^^^^ TC004 -58 | +58 | 59 | def func(value: DataFrame): | = help: Quote references @@ -26,7 +26,7 @@ quote.py:110:28: TC004 [*] Move import `pandas.DataFrame` out of type-checking b 109 | if TYPE_CHECKING: 110 | from pandas import DataFrame | ^^^^^^^^^ TC004 -111 | +111 | 112 | x: TypeAlias = DataFrame | None | = help: Move out of type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote.py.snap index 593464accbda6..89ab3746f0602 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- quote.py:2:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block | 1 | def f(): 2 | from pandas import DataFrame | ^^^^^^^^^ TC002 -3 | +3 | 4 | def baz() -> DataFrame: | = help: Move into type-checking block @@ -31,7 +30,7 @@ quote.py:9:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type- 8 | def f(): 9 | from pandas import DataFrame | ^^^^^^^^^ TC002 -10 | +10 | 11 | def baz() -> DataFrame[int]: | = help: Move into type-checking block @@ -61,7 +60,7 @@ quote.py:16:22: TC002 [*] Move third-party import `pandas` into a type-checking 15 | def f(): 16 | import pandas as pd | ^^ TC002 -17 | +17 | 18 | def baz() -> pd.DataFrame: | = help: Move into type-checking block @@ -91,7 +90,7 @@ quote.py:23:22: TC002 [*] Move third-party import `pandas` into a type-checking 22 | def f(): 23 | import pandas as pd | ^^ TC002 -24 | +24 | 25 | def baz() -> pd.DataFrame.Extra: | = help: Move into type-checking block @@ -121,7 +120,7 @@ quote.py:30:22: TC002 [*] Move third-party import `pandas` into a type-checking 29 | def f(): 30 | import pandas as pd | ^^ TC002 -31 | +31 | 32 | def baz() -> pd.DataFrame | int: | = help: Move into type-checking block @@ -151,7 +150,7 @@ quote.py:38:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type 37 | def f(): 38 | from pandas import DataFrame | ^^^^^^^^^ TC002 -39 | +39 | 40 | def baz() -> DataFrame(): | = help: Move into type-checking block @@ -179,10 +178,10 @@ quote.py:38:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type quote.py:47:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block | 45 | from typing import Literal -46 | +46 | 47 | from pandas import DataFrame | ^^^^^^^^^ TC002 -48 | +48 | 49 | def baz() -> DataFrame[Literal["int"]]: | = help: Move into type-checking block @@ -212,7 +211,7 @@ quote.py:64:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type 63 | def f(): 64 | from pandas import DataFrame, Series | ^^^^^^^^^ TC002 -65 | +65 | 66 | def baz() -> DataFrame | Series: | = help: Move into type-checking block @@ -242,7 +241,7 @@ quote.py:64:35: TC002 [*] Move third-party import `pandas.Series` into a type-ch 63 | def f(): 64 | from pandas import DataFrame, Series | ^^^^^^ TC002 -65 | +65 | 66 | def baz() -> DataFrame | Series: | = help: Move into type-checking block @@ -272,7 +271,7 @@ quote.py:71:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type 70 | def f(): 71 | from pandas import DataFrame, Series | ^^^^^^^^^ TC002 -72 | +72 | 73 | def baz() -> ( | = help: Move into type-checking block @@ -315,7 +314,7 @@ quote.py:71:35: TC002 [*] Move third-party import `pandas.Series` into a type-ch 70 | def f(): 71 | from pandas import DataFrame, Series | ^^^^^^ TC002 -72 | +72 | 73 | def baz() -> ( | = help: Move into type-checking block @@ -358,7 +357,7 @@ quote.py:89:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type 88 | def f(): 89 | from pandas import DataFrame, Series | ^^^^^^^^^ TC002 -90 | +90 | 91 | def func(self) -> DataFrame | list[Series]: | = help: Move into type-checking block @@ -388,7 +387,7 @@ quote.py:89:35: TC002 [*] Move third-party import `pandas.Series` into a type-ch 88 | def f(): 89 | from pandas import DataFrame, Series | ^^^^^^ TC002 -90 | +90 | 91 | def func(self) -> DataFrame | list[Series]: | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote2.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote2.py.snap index 7401bf3092bca..747fe681ccda5 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote2.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- quote2.py:2:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block | 1 | def f(): 2 | from django.contrib.auth.models import AbstractBaseUser | ^^^^^^^^^^^^^^^^ TC002 -3 | +3 | 4 | def test_remove_inner_quotes_double(self, user: AbstractBaseUser["int"]): | = help: Move into type-checking block @@ -31,7 +30,7 @@ quote2.py:9:44: TC002 [*] Move third-party import `django.contrib.auth.models.Ab 8 | def f(): 9 | from django.contrib.auth.models import AbstractBaseUser | ^^^^^^^^^^^^^^^^ TC002 -10 | +10 | 11 | def test_remove_inner_quotes_single(self, user: AbstractBaseUser['int']): | = help: Move into type-checking block @@ -61,7 +60,7 @@ quote2.py:16:44: TC002 [*] Move third-party import `django.contrib.auth.models.A 15 | def f(): 16 | from django.contrib.auth.models import AbstractBaseUser | ^^^^^^^^^^^^^^^^ TC002 -17 | +17 | 18 | def test_remove_inner_quotes_mixed(self, user: AbstractBaseUser['int', "str"]): | = help: Move into type-checking block @@ -89,10 +88,10 @@ quote2.py:16:44: TC002 [*] Move third-party import `django.contrib.auth.models.A quote2.py:25:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block | 23 | from typing import Annotated, Literal -24 | +24 | 25 | from django.contrib.auth.models import AbstractBaseUser | ^^^^^^^^^^^^^^^^ TC002 -26 | +26 | 27 | def test_literal_annotation_args_contain_quotes(self, type1: AbstractBaseUser[Literal["user", "admin"], Annotated["int", "1", 2]]): | = help: Move into type-checking block @@ -120,10 +119,10 @@ quote2.py:25:44: TC002 [*] Move third-party import `django.contrib.auth.models.A quote2.py:34:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block | 32 | from typing import Literal -33 | +33 | 34 | from django.contrib.auth.models import AbstractBaseUser | ^^^^^^^^^^^^^^^^ TC002 -35 | +35 | 36 | def test_union_contain_inner_quotes(self, type1: AbstractBaseUser["int" | Literal["int"]]): | = help: Move into type-checking block @@ -151,10 +150,10 @@ quote2.py:34:44: TC002 [*] Move third-party import `django.contrib.auth.models.A quote2.py:43:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block | 41 | from typing import Literal -42 | +42 | 43 | from django.contrib.auth.models import AbstractBaseUser | ^^^^^^^^^^^^^^^^ TC002 -44 | +44 | 45 | def test_inner_literal_mixed_quotes(user: AbstractBaseUser[Literal['user', "admin"]]): | = help: Move into type-checking block @@ -182,10 +181,10 @@ quote2.py:43:44: TC002 [*] Move third-party import `django.contrib.auth.models.A quote2.py:52:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block | 50 | from typing import Literal -51 | +51 | 52 | from django.contrib.auth.models import AbstractBaseUser | ^^^^^^^^^^^^^^^^ TC002 -53 | +53 | 54 | def test_inner_literal_single_quote(user: AbstractBaseUser[Literal['int'], str]): | = help: Move into type-checking block @@ -213,10 +212,10 @@ quote2.py:52:44: TC002 [*] Move third-party import `django.contrib.auth.models.A quote2.py:61:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block | 59 | from typing import Literal -60 | +60 | 61 | from django.contrib.auth.models import AbstractBaseUser | ^^^^^^^^^^^^^^^^ TC002 -62 | +62 | 63 | def test_mixed_quotes_literal(user: AbstractBaseUser[Literal['user'], "int"]): | = help: Move into type-checking block @@ -244,10 +243,10 @@ quote2.py:61:44: TC002 [*] Move third-party import `django.contrib.auth.models.A quote2.py:70:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block | 68 | from typing import Annotated, Literal -69 | +69 | 70 | from django.contrib.auth.models import AbstractBaseUser | ^^^^^^^^^^^^^^^^ TC002 -71 | +71 | 72 | def test_annotated_literal_mixed_quotes(user: AbstractBaseUser[Annotated[str, "max_length=20", Literal['user', "admin"]]]): | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quoted-type-alias_TC008.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quoted-type-alias_TC008.py.snap index 76545b56fd779..626c985dbe4e9 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quoted-type-alias_TC008.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quoted-type-alias_TC008.py.snap @@ -4,7 +4,7 @@ source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs TC008.py:15:16: TC008 [*] Remove quotes from type alias | 13 | Bar = Foo -14 | +14 | 15 | a: TypeAlias = 'int' # TC008 | ^^^^^ TC008 16 | b: TypeAlias = 'Dict' # OK @@ -156,7 +156,7 @@ TC008.py:29:17: TC008 [*] Remove quotes from type alias | _________________^ 30 | | ' | None') | |_____________^ TC008 -31 | +31 | 32 | type B = 'Dict' # TC008 | = help: Remove quotes @@ -175,7 +175,7 @@ TC008.py:29:17: TC008 [*] Remove quotes from type alias TC008.py:32:10: TC008 [*] Remove quotes from type alias | 30 | ' | None') -31 | +31 | 32 | type B = 'Dict' # TC008 | ^^^^^^ TC008 33 | type D = 'Foo[str]' # TC008 @@ -388,7 +388,7 @@ TC008.py:48:14: TC008 [*] Remove quotes from type alias 47 | a: TypeAlias = 'Baz' # OK 48 | type A = 'Baz' # TC008 | ^^^^^ TC008 -49 | +49 | 50 | class Nested: | = help: Remove quotes diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quoted-type-alias_TC008_typing_execution_context.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quoted-type-alias_TC008_typing_execution_context.py.snap index 0da908ea8ef87..c3b71b50dea6b 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quoted-type-alias_TC008_typing_execution_context.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quoted-type-alias_TC008_typing_execution_context.py.snap @@ -4,7 +4,7 @@ source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs TC008_typing_execution_context.py:13:20: TC008 [*] Remove quotes from type alias | 11 | Bar: TypeAlias = Foo[int] -12 | +12 | 13 | a: TypeAlias = 'int' # TC008 | ^^^^^ TC008 14 | b: TypeAlias = 'Dict' # TC008 diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_11.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_11.py.snap index 74ba7d464e18e..b9858550b26a7 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_11.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_11.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- TC004_11.py:4:24: TC004 [*] Move import `typing.List` out of type-checking block. Import is used for more than type hinting. | 3 | if TYPE_CHECKING: 4 | from typing import List | ^^^^ TC004 -5 | +5 | 6 | __all__ = ("List",) | = help: Move out of type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_12.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_12.py.snap index 9d22eb24bf73e..52ee66998cdd1 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_12.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_12.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- TC004_12.py:6:33: TC004 [*] Move import `collections.abc.Callable` out of type-checking block. Import is used for more than type hinting. | 5 | if TYPE_CHECKING: 6 | from collections.abc import Callable | ^^^^^^^^ TC004 -7 | +7 | 8 | AnyCallable: TypeAlias = Callable[..., Any] | = help: Move out of type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_9.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_9.py.snap index 765fd57c616c2..29514c37a1e78 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_9.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_9.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- TC004_9.py:4:24: TC004 [*] Move import `typing.Tuple` out of type-checking block. Import is used for more than type hinting. | 3 | if TYPE_CHECKING: 4 | from typing import Tuple, List, Dict | ^^^^^ TC004 -5 | +5 | 6 | x: Tuple | = help: Move out of type-checking block @@ -28,7 +27,7 @@ TC004_9.py:4:31: TC004 [*] Move import `typing.List` out of type-checking block. 3 | if TYPE_CHECKING: 4 | from typing import Tuple, List, Dict | ^^^^ TC004 -5 | +5 | 6 | x: Tuple | = help: Move out of type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_module__app.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_module__app.py.snap index 8c73eb30adcfa..436e35992ba77 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_module__app.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_module__app.py.snap @@ -28,7 +28,7 @@ app.py:10:23: TC004 [*] Move import `array.array` out of type-checking block. Im 9 | import datetime # TC004 10 | from array import array # TC004 | ^^^^^ TC004 -11 | +11 | 12 | app = fastapi.FastAPI("First application") | = help: Move out of type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_quote.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_quote.py.snap index 4d4f252faf964..dbb418b692ac7 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_quote.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_quote.py.snap @@ -6,7 +6,7 @@ quote.py:57:28: TC004 [*] Move import `pandas.DataFrame` out of type-checking bl 56 | if TYPE_CHECKING: 57 | from pandas import DataFrame | ^^^^^^^^^ TC004 -58 | +58 | 59 | def func(value: DataFrame): | = help: Move out of type-checking block @@ -31,7 +31,7 @@ quote.py:110:28: TC004 [*] Move import `pandas.DataFrame` out of type-checking b 109 | if TYPE_CHECKING: 110 | from pandas import DataFrame | ^^^^^^^^^ TC004 -111 | +111 | 112 | x: TypeAlias = DataFrame | None | = help: Move out of type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_base_classes_1.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_base_classes_1.py.snap index 689abb0884138..70d301b0b5ab6 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_base_classes_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_base_classes_1.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- runtime_evaluated_base_classes_1.py:10:12: TC004 [*] Move import `datetime` out of type-checking block. Import is used for more than type hinting. | @@ -29,7 +28,7 @@ runtime_evaluated_base_classes_1.py:11:23: TC004 [*] Move import `array.array` o 10 | import datetime # TC004 11 | from array import array # TC004 | ^^^^^ TC004 -12 | +12 | 13 | import pandas # TC004 | = help: Move out of type-checking block @@ -50,7 +49,7 @@ runtime_evaluated_base_classes_1.py:11:23: TC004 [*] Move import `array.array` o runtime_evaluated_base_classes_1.py:13:12: TC004 [*] Move import `pandas` out of type-checking block. Import is used for more than type hinting. | 11 | from array import array # TC004 -12 | +12 | 13 | import pandas # TC004 | ^^^^^^ TC004 14 | import pyproj diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_decorators_1.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_decorators_1.py.snap index e0a3725545a59..bab0a4ba6372a 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_decorators_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_decorators_1.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- runtime_evaluated_decorators_1.py:12:12: TC004 [*] Move import `datetime` out of type-checking block. Import is used for more than type hinting. | @@ -29,7 +28,7 @@ runtime_evaluated_decorators_1.py:13:23: TC004 [*] Move import `array.array` out 12 | import datetime # TC004 13 | from array import array # TC004 | ^^^^^ TC004 -14 | +14 | 15 | import pandas # TC004 | = help: Move out of type-checking block @@ -50,7 +49,7 @@ runtime_evaluated_decorators_1.py:13:23: TC004 [*] Move import `array.array` out runtime_evaluated_decorators_1.py:15:12: TC004 [*] Move import `pandas` out of type-checking block. Import is used for more than type hinting. | 13 | from array import array # TC004 -14 | +14 | 15 | import pandas # TC004 | ^^^^^^ TC004 16 | import pyproj diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-string-union_TC010_1.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-string-union_TC010_1.py.snap index c4db736188e05..364d44103bdcb 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-string-union_TC010_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-string-union_TC010_1.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- TC010_1.py:18:30: TC010 Invalid string member in `X | Y`-style union type | 16 | type A = Value["int" | str] # OK -17 | +17 | 18 | OldS = TypeVar('OldS', int | 'str', str) # TC010 | ^^^^^ TC010 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-string-union_TC010_2.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-string-union_TC010_2.py.snap index 2dc80f40e266f..1e169cb50c493 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-string-union_TC010_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-string-union_TC010_2.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- TC010_2.py:4:4: TC010 Invalid string member in `X | Y`-style union type | @@ -27,14 +26,14 @@ TC010_2.py:12:20: TC010 Invalid string member in `X | Y`-style union type | 12 | z: list[str, str | "int"] = [] # TC010 | ^^^^^ TC010 -13 | +13 | 14 | type A = Value["int" | str] # OK | TC010_2.py:16:30: TC010 Invalid string member in `X | Y`-style union type | 14 | type A = Value["int" | str] # OK -15 | +15 | 16 | OldS = TypeVar('OldS', int | 'str', str) # TC010 | ^^^^^ TC010 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-standard-library-import_init_var.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-standard-library-import_init_var.py.snap index 35e5ef0a4e506..b5260d86db131 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-standard-library-import_init_var.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-standard-library-import_init_var.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- init_var.py:5:25: TC003 [*] Move standard library import `dataclasses.FrozenInstanceError` into a type-checking block | 3 | from __future__ import annotations -4 | +4 | 5 | from dataclasses import FrozenInstanceError, InitVar, dataclass | ^^^^^^^^^^^^^^^^^^^ TC003 6 | from pathlib import Path diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-standard-library-import_kw_only.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-standard-library-import_kw_only.py.snap index 08742fa65e8e7..541a83ad172bf 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-standard-library-import_kw_only.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-standard-library-import_kw_only.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- kw_only.py:5:45: TC003 [*] Move standard library import `dataclasses.Field` into a type-checking block | 3 | from __future__ import annotations -4 | +4 | 5 | from dataclasses import KW_ONLY, dataclass, Field | ^^^^^ TC003 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-third-party-import_strict.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-third-party-import_strict.py.snap index ca5ceb2983776..d8451b6dfb301 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-third-party-import_strict.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-third-party-import_strict.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- strict.py:27:21: TC002 [*] Move third-party import `pkg.A` into a type-checking block | @@ -8,7 +7,7 @@ strict.py:27:21: TC002 [*] Move third-party import `pkg.A` into a type-checking 26 | import pkg 27 | from pkg import A | ^ TC002 -28 | +28 | 29 | def test(value: A): | = help: Move into type-checking block @@ -37,7 +36,7 @@ strict.py:35:21: TC002 [*] Move third-party import `pkg.A` into a type-checking 34 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime. 35 | from pkg import A, B | ^ TC002 -36 | +36 | 37 | def test(value: A): | = help: Move into type-checking block @@ -67,7 +66,7 @@ strict.py:54:25: TC002 [*] Move third-party import `pkg.bar.A` into a type-check 53 | import pkg 54 | from pkg.bar import A | ^ TC002 -55 | +55 | 56 | def test(value: A): | = help: Move into type-checking block @@ -208,7 +207,7 @@ strict.py:101:23: TC002 [*] Move third-party import `pkg.foo` into a type-checki 100 | import pkg.bar as B 101 | import pkg.foo as F | ^ TC002 -102 | +102 | 103 | def test(value: F.Foo): | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__tc004_precedence_over_tc007.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__tc004_precedence_over_tc007.snap index 41b0f9408f261..b4ae0f7ff9e1a 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__tc004_precedence_over_tc007.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__tc004_precedence_over_tc007.snap @@ -7,7 +7,7 @@ source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs 5 | if TYPE_CHECKING: 6 | from foo import Foo # TC004 | ^^^ TC004 -7 | +7 | 8 | a: TypeAlias = Foo | None # OK | = help: Move out of type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__tc010_precedence_over_tc008.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__tc010_precedence_over_tc008.snap index 2d30b115db7e0..3f7510c00fa32 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__tc010_precedence_over_tc008.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__tc010_precedence_over_tc008.snap @@ -4,7 +4,7 @@ source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs :6:16: TC008 [*] Remove quotes from type alias | 4 | from typing import TypeAlias -5 | +5 | 6 | a: TypeAlias = 'int | None' # TC008 | ^^^^^^^^^^^^ TC008 7 | b: TypeAlias = 'int' | None # TC010 diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_after_usage.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_after_usage.snap index 23e2c0e0ff3bd..cdacd1ba29ac6 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_after_usage.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_after_usage.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- :6:18: TC002 [*] Move third-party import `pandas` into a type-checking block | 4 | from typing import TYPE_CHECKING -5 | +5 | 6 | import pandas as pd | ^^ TC002 -7 | +7 | 8 | def f(x: pd.DataFrame): | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_comment.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_comment.snap index 06cc0d470017c..ce5864c57dd46 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_comment.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_comment.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- :6:18: TC002 [*] Move third-party import `pandas` into a type-checking block | 4 | from typing import TYPE_CHECKING -5 | +5 | 6 | import pandas as pd | ^^ TC002 -7 | +7 | 8 | if TYPE_CHECKING: | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_inline.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_inline.snap index 946226bbecd79..bafccc1d138f3 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_inline.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_inline.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- :6:18: TC002 [*] Move third-party import `pandas` into a type-checking block | 4 | from typing import TYPE_CHECKING -5 | +5 | 6 | import pandas as pd | ^^ TC002 -7 | +7 | 8 | if TYPE_CHECKING: import os | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_own_line.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_own_line.snap index ecb1a3e892e42..ac2f55bc5a11a 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_own_line.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_own_line.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- :6:18: TC002 [*] Move third-party import `pandas` into a type-checking block | 4 | from typing import TYPE_CHECKING -5 | +5 | 6 | import pandas as pd | ^^ TC002 -7 | +7 | 8 | if TYPE_CHECKING: | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-first-party-import_TC001.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-first-party-import_TC001.py.snap index 3ea3a853b8f0e..cc9d12d169811 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-first-party-import_TC001.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-first-party-import_TC001.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- TC001.py:20:19: TC001 [*] Move application import `.TYP001` into a type-checking block | 19 | def f(): 20 | from . import TYP001 | ^^^^^^ TC001 -21 | +21 | 22 | x: TYP001 | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_TC003.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_TC003.py.snap index d527f4ccb1820..e7590ea5c254f 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_TC003.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_TC003.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- TC003.py:8:12: TC003 [*] Move standard library import `os` into a type-checking block | 7 | def f(): 8 | import os | ^^ TC003 - 9 | + 9 | 10 | x: os | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_1.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_1.py.snap index 0e97a464641fb..98f48ef06a17c 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_1.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- exempt_type_checking_1.py:5:20: TC003 [*] Move standard library import `typing.Final` into a type-checking block | 3 | from __future__ import annotations -4 | +4 | 5 | from typing import Final | ^^^^^ TC003 -6 | +6 | 7 | Const: Final[dict] = {} | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_2.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_2.py.snap index 32cf29f776503..909e0d5530f97 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_2.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- exempt_type_checking_2.py:5:20: TC003 [*] Move standard library import `typing.Final` into a type-checking block | 3 | from __future__ import annotations -4 | +4 | 5 | from typing import Final, TYPE_CHECKING | ^^^^^ TC003 -6 | +6 | 7 | Const: Final[dict] = {} | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_3.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_3.py.snap index c93a7aba9ac26..afd7480adef73 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_3.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_3.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- exempt_type_checking_3.py:5:20: TC003 [*] Move standard library import `typing.Final` into a type-checking block | 3 | from __future__ import annotations -4 | +4 | 5 | from typing import Final, Mapping | ^^^^^ TC003 -6 | +6 | 7 | Const: Final[dict] = {} | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_module__undefined.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_module__undefined.py.snap index 490c756534e3b..89f0a91947d4a 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_module__undefined.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_module__undefined.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- undefined.py:3:29: TC003 [*] Move standard library import `collections.abc.Sequence` into a type-checking block | 1 | from __future__ import annotations -2 | +2 | 3 | from collections.abc import Sequence | ^^^^^^^^ TC003 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_base_classes_3.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_base_classes_3.py.snap index 95cf17c1626af..06d344ed01523 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_base_classes_3.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_base_classes_3.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- runtime_evaluated_base_classes_3.py:5:18: TC003 [*] Move standard library import `uuid.UUID` into a type-checking block | @@ -8,7 +7,7 @@ runtime_evaluated_base_classes_3.py:5:18: TC003 [*] Move standard library import 4 | import pathlib 5 | from uuid import UUID # TC003 | ^^^^ TC003 -6 | +6 | 7 | import pydantic | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_TC002.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_TC002.py.snap index 3c59bc98ee82e..3b34f3141cd25 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_TC002.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_TC002.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- TC002.py:5:22: TC002 [*] Move third-party import `pandas` into a type-checking block | 4 | def f(): 5 | import pandas as pd # TC002 | ^^ TC002 -6 | +6 | 7 | x: pd.DataFrame | = help: Move into type-checking block @@ -31,7 +30,7 @@ TC002.py:11:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type 10 | def f(): 11 | from pandas import DataFrame # TC002 | ^^^^^^^^^ TC002 -12 | +12 | 13 | x: DataFrame | = help: Move into type-checking block @@ -59,7 +58,7 @@ TC002.py:17:37: TC002 [*] Move third-party import `pandas.DataFrame` into a type 16 | def f(): 17 | from pandas import DataFrame as df # TC002 | ^^ TC002 -18 | +18 | 19 | x: df | = help: Move into type-checking block @@ -87,7 +86,7 @@ TC002.py:23:22: TC002 [*] Move third-party import `pandas` into a type-checking 22 | def f(): 23 | import pandas as pd # TC002 | ^^ TC002 -24 | +24 | 25 | x: pd.DataFrame = 1 | = help: Move into type-checking block @@ -115,7 +114,7 @@ TC002.py:29:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type 28 | def f(): 29 | from pandas import DataFrame # TC002 | ^^^^^^^^^ TC002 -30 | +30 | 31 | x: DataFrame = 2 | = help: Move into type-checking block @@ -143,7 +142,7 @@ TC002.py:35:37: TC002 [*] Move third-party import `pandas.DataFrame` into a type 34 | def f(): 35 | from pandas import DataFrame as df # TC002 | ^^ TC002 -36 | +36 | 37 | x: df = 3 | = help: Move into type-checking block @@ -171,7 +170,7 @@ TC002.py:41:22: TC002 [*] Move third-party import `pandas` into a type-checking 40 | def f(): 41 | import pandas as pd # TC002 | ^^ TC002 -42 | +42 | 43 | x: "pd.DataFrame" = 1 | = help: Move into type-checking block @@ -199,7 +198,7 @@ TC002.py:47:22: TC002 [*] Move third-party import `pandas` into a type-checking 46 | def f(): 47 | import pandas as pd # TC002 | ^^ TC002 -48 | +48 | 49 | x = dict["pd.DataFrame", "pd.DataFrame"] | = help: Move into type-checking block @@ -225,10 +224,10 @@ TC002.py:47:22: TC002 [*] Move third-party import `pandas` into a type-checking TC002.py:172:24: TC002 [*] Move third-party import `module.Member` into a type-checking block | 170 | global Member -171 | +171 | 172 | from module import Member | ^^^^^^ TC002 -173 | +173 | 174 | x: Member = 1 | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_base_classes_2.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_base_classes_2.py.snap index f8634941ee460..d52dd420f81f9 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_base_classes_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_base_classes_2.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- runtime_evaluated_base_classes_2.py:3:21: TC002 [*] Move third-party import `geopandas` into a type-checking block | 1 | from __future__ import annotations -2 | +2 | 3 | import geopandas as gpd # TC002 | ^^^ TC002 4 | import pydantic diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_decorators_2.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_decorators_2.py.snap index b78f6b46733d2..daf471f921697 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_decorators_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_decorators_2.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- runtime_evaluated_decorators_2.py:10:8: TC002 [*] Move third-party import `numpy` into a type-checking block | 8 | from attrs import frozen - 9 | + 9 | 10 | import numpy # TC002 | ^^^^^ TC002 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_singledispatch.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_singledispatch.py.snap index 157d972cd356a..c226a6cfd13e3 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_singledispatch.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_singledispatch.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- singledispatch.py:12:20: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block | @@ -8,7 +7,7 @@ singledispatch.py:12:20: TC002 [*] Move third-party import `pandas.DataFrame` in 11 | from scipy.sparse import spmatrix 12 | from pandas import DataFrame | ^^^^^^^^^ TC002 -13 | +13 | 14 | if TYPE_CHECKING: | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_strict.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_strict.py.snap index d1cd9de5996d4..94b85230ae819 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_strict.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_strict.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- strict.py:54:25: TC002 [*] Move third-party import `pkg.bar.A` into a type-checking block | @@ -8,7 +7,7 @@ strict.py:54:25: TC002 [*] Move third-party import `pkg.bar.A` into a type-check 53 | import pkg 54 | from pkg.bar import A | ^ TC002 -55 | +55 | 56 | def test(value: A): | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_1.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_1.py.snap index 76f2c216a29ae..d02dab7f4a28e 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_1.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- typing_modules_1.py:7:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block | 6 | def func(): 7 | from pandas import DataFrame | ^^^^^^^^^ TC002 -8 | +8 | 9 | df: DataFrame | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_2.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_2.py.snap index c9f5129aa83ab..ba8a621fcce77 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_2.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- typing_modules_2.py:7:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block | 6 | def func(): 7 | from pandas import DataFrame | ^^^^^^^^^ TC002 -8 | +8 | 9 | df: DataFrame | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_package_import.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_package_import.snap index 1179b87df9bae..4c00f741029c0 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_package_import.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_package_import.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- :4:18: TC002 [*] Move third-party import `pandas` into a type-checking block | 2 | from __future__ import annotations -3 | +3 | 4 | import pandas as pd | ^^ TC002 -5 | +5 | 6 | from typing import TYPE_CHECKING | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_usage.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_usage.snap index 38771b04fb5f0..d5353c093997c 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_usage.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_usage.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- :4:18: TC002 Move third-party import `pandas` into a type-checking block | 2 | from __future__ import annotations -3 | +3 | 4 | import pandas as pd | ^^ TC002 -5 | +5 | 6 | def f(x: pd.DataFrame): | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_before_package_import.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_before_package_import.snap index c080a0659ee44..581f1bb10f6d5 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_before_package_import.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_before_package_import.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- :6:18: TC002 [*] Move third-party import `pandas` into a type-checking block | 4 | from typing import TYPE_CHECKING -5 | +5 | 6 | import pandas as pd | ^^ TC002 -7 | +7 | 8 | def f(x: pd.DataFrame): | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__unquoted-type-alias_TC007.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__unquoted-type-alias_TC007.py.snap index ddc70534e7bea..5ce4bcc79fcf5 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__unquoted-type-alias_TC007.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__unquoted-type-alias_TC007.py.snap @@ -175,7 +175,7 @@ TC007.py:22:5: TC007 [*] Add quotes to type alias 21 | i: TypeAlias = (Foo | # TC007 x2 (fix removes comment currently) 22 | Bar) | ^^^ TC007 -23 | +23 | 24 | type C = Foo # OK | = help: Add quotes diff --git a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG002_ARG.py.snap b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG002_ARG.py.snap index b1b8ae68ff9a0..0bd147a3e9f4e 100644 --- a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG002_ARG.py.snap +++ b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG002_ARG.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_unused_arguments/mod.rs -snapshot_kind: text --- ARG.py:37:17: ARG002 Unused method argument: `x` | @@ -14,7 +13,7 @@ ARG.py:37:17: ARG002 Unused method argument: `x` ARG.py:40:20: ARG002 Unused method argument: `x` | 38 | print("Hello, world!") -39 | +39 | 40 | def f(self, /, x): | ^ ARG002 41 | print("Hello, world!") @@ -23,7 +22,7 @@ ARG.py:40:20: ARG002 Unused method argument: `x` ARG.py:43:16: ARG002 Unused method argument: `x` | 41 | print("Hello, world!") -42 | +42 | 43 | def f(cls, x): | ^ ARG002 44 | print("Hello, world!") @@ -32,7 +31,7 @@ ARG.py:43:16: ARG002 Unused method argument: `x` ARG.py:58:17: ARG002 Unused method argument: `x` | 56 | print("Hello, world!") -57 | +57 | 58 | def f(self, x): | ^ ARG002 59 | msg[0] = "..." @@ -42,7 +41,7 @@ ARG.py:58:17: ARG002 Unused method argument: `x` ARG.py:62:17: ARG002 Unused method argument: `x` | 60 | raise NotImplementedError(msg) -61 | +61 | 62 | def f(self, x): | ^ ARG002 63 | msg = "..." @@ -52,7 +51,7 @@ ARG.py:62:17: ARG002 Unused method argument: `x` ARG.py:66:17: ARG002 Unused method argument: `x` | 64 | raise NotImplementedError(foo) -65 | +65 | 66 | def f(self, x): | ^ ARG002 67 | msg = "..." diff --git a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG005_ARG.py.snap b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG005_ARG.py.snap index 3f54ce449f10e..db2dbbab7851a 100644 --- a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG005_ARG.py.snap +++ b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG005_ARG.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_unused_arguments/mod.rs -snapshot_kind: text --- ARG.py:28:8: ARG005 Unused lambda argument: `x` | @@ -8,6 +7,6 @@ ARG.py:28:8: ARG005 Unused lambda argument: `x` 27 | ### 28 | lambda x: print("Hello, world!") | ^ ARG005 -29 | +29 | 30 | lambda: print("Hello, world!") | diff --git a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__enforce_variadic_names.snap b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__enforce_variadic_names.snap index 21ec1b0eb1e22..430bd44bb2d03 100644 --- a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__enforce_variadic_names.snap +++ b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__enforce_variadic_names.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_unused_arguments/mod.rs -snapshot_kind: text --- ignore_variadic_names.py:1:7: ARG001 Unused function argument: `a` | @@ -63,7 +62,7 @@ ignore_variadic_names.py:10:20: ARG002 Unused method argument: `b` ignore_variadic_names.py:13:17: ARG002 Unused method argument: `a` | 11 | print("Hello, world!") -12 | +12 | 13 | def f(self, a, b, *args, **kwargs): | ^ ARG002 14 | print("Hello, world!") @@ -72,7 +71,7 @@ ignore_variadic_names.py:13:17: ARG002 Unused method argument: `a` ignore_variadic_names.py:13:20: ARG002 Unused method argument: `b` | 11 | print("Hello, world!") -12 | +12 | 13 | def f(self, a, b, *args, **kwargs): | ^ ARG002 14 | print("Hello, world!") @@ -81,7 +80,7 @@ ignore_variadic_names.py:13:20: ARG002 Unused method argument: `b` ignore_variadic_names.py:13:24: ARG002 Unused method argument: `args` | 11 | print("Hello, world!") -12 | +12 | 13 | def f(self, a, b, *args, **kwargs): | ^^^^ ARG002 14 | print("Hello, world!") @@ -90,7 +89,7 @@ ignore_variadic_names.py:13:24: ARG002 Unused method argument: `args` ignore_variadic_names.py:13:32: ARG002 Unused method argument: `kwargs` | 11 | print("Hello, world!") -12 | +12 | 13 | def f(self, a, b, *args, **kwargs): | ^^^^^^ ARG002 14 | print("Hello, world!") diff --git a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ignore_variadic_names.snap b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ignore_variadic_names.snap index 3702d0d84939e..16e2230d2c832 100644 --- a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ignore_variadic_names.snap +++ b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ignore_variadic_names.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_unused_arguments/mod.rs -snapshot_kind: text --- ignore_variadic_names.py:1:7: ARG001 Unused function argument: `a` | @@ -49,7 +48,7 @@ ignore_variadic_names.py:10:20: ARG002 Unused method argument: `b` ignore_variadic_names.py:13:17: ARG002 Unused method argument: `a` | 11 | print("Hello, world!") -12 | +12 | 13 | def f(self, a, b, *args, **kwargs): | ^ ARG002 14 | print("Hello, world!") @@ -58,7 +57,7 @@ ignore_variadic_names.py:13:17: ARG002 Unused method argument: `a` ignore_variadic_names.py:13:20: ARG002 Unused method argument: `b` | 11 | print("Hello, world!") -12 | +12 | 13 | def f(self, a, b, *args, **kwargs): | ^ ARG002 14 | print("Hello, world!") diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH124_py_path_1.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH124_py_path_1.py.snap index 6a27ee2653ac1..bea8d4778a18e 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH124_py_path_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH124_py_path_1.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs -snapshot_kind: text --- py_path_1.py:3:5: PTH124 `py.path` is in maintenance mode, use `pathlib` instead | 1 | import py -2 | +2 | 3 | p = py.path.local("../foo") | ^^^^^^^^^^^^^ PTH124 | diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH124_py_path_2.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH124_py_path_2.py.snap index fcc8f00471fa5..f5b5e5c089e2f 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH124_py_path_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH124_py_path_2.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs -snapshot_kind: text --- py_path_2.py:3:5: PTH124 `py.path` is in maintenance mode, use `pathlib` instead | 1 | from py.path import local as path -2 | +2 | 3 | p = path("/foo") | ^^^^ PTH124 | diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH202_PTH202.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH202_PTH202.py.snap index 51311bf3993ab..4f2fd0ce76387 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH202_PTH202.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH202_PTH202.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs -snapshot_kind: text --- PTH202.py:6:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` | @@ -34,14 +33,14 @@ PTH202.py:9:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_si 8 | os.path.getsize(Path("filename")) 9 | os.path.getsize(__file__) | ^^^^^^^^^^^^^^^ PTH202 -10 | +10 | 11 | getsize("filename") | PTH202.py:11:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` | 9 | os.path.getsize(__file__) -10 | +10 | 11 | getsize("filename") | ^^^^^^^ PTH202 12 | getsize(b"filename") diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH203_PTH203.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH203_PTH203.py.snap index 9e3f3de4739a0..8851d9d32ab15 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH203_PTH203.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH203_PTH203.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs -snapshot_kind: text --- PTH203.py:5:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` | 3 | from os.path import getatime -4 | +4 | 5 | os.path.getatime("filename") | ^^^^^^^^^^^^^^^^ PTH203 6 | os.path.getatime(b"filename") diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH205_PTH205.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH205_PTH205.py.snap index bfa2aefd0e8d4..3edeac694e549 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH205_PTH205.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH205_PTH205.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs -snapshot_kind: text --- PTH205.py:6:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` | @@ -24,14 +23,14 @@ PTH205.py:8:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_c 7 | os.path.getctime(b"filename") 8 | os.path.getctime(Path("filename")) | ^^^^^^^^^^^^^^^^ PTH205 - 9 | + 9 | 10 | getctime("filename") | PTH205.py:10:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` | 8 | os.path.getctime(Path("filename")) - 9 | + 9 | 10 | getctime("filename") | ^^^^^^^^ PTH205 11 | getctime(b"filename") diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH206_PTH206.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH206_PTH206.py.snap index 0fc3af2ead543..70e6338726ba1 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH206_PTH206.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH206_PTH206.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs -snapshot_kind: text --- PTH206.py:8:12: PTH206 Replace `.split(os.sep)` with `Path.parts` | @@ -96,6 +95,6 @@ PTH206.py:17:30: PTH206 Replace `.split(os.sep)` with `Path.parts` 16 | file_name.split(os.sep) 17 | (os.path.abspath(file_name)).split(os.sep) | ^^^^^ PTH206 -18 | +18 | 19 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH208_PTH208.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH208_PTH208.py.snap index 27d5009df016d..f8dfff97ec1ab 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH208_PTH208.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH208_PTH208.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs -snapshot_kind: text --- PTH208.py:3:1: PTH208 Use `pathlib.Path.iterdir()` instead. | 1 | import os -2 | +2 | 3 | os.listdir('.') | ^^^^^^^^^^ PTH208 4 | os.listdir(b'.') @@ -16,7 +15,7 @@ PTH208.py:4:1: PTH208 Use `pathlib.Path.iterdir()` instead. 3 | os.listdir('.') 4 | os.listdir(b'.') | ^^^^^^^^^^ PTH208 -5 | +5 | 6 | string_path = '.' | @@ -25,7 +24,7 @@ PTH208.py:7:1: PTH208 Use `pathlib.Path.iterdir()` instead. 6 | string_path = '.' 7 | os.listdir(string_path) | ^^^^^^^^^^ PTH208 -8 | +8 | 9 | bytes_path = b'.' | @@ -53,7 +52,7 @@ PTH208.py:19:4: PTH208 Use `pathlib.Path.iterdir()` instead. PTH208.py:22:14: PTH208 Use `pathlib.Path.iterdir()` instead. | 20 | ... -21 | +21 | 22 | if "file" in os.listdir("dir"): | ^^^^^^^^^^ PTH208 23 | ... diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH210_PTH210.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH210_PTH210.py.snap index 289e4fbef6f80..157a100789d57 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH210_PTH210.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH210_PTH210.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs -snapshot_kind: text --- PTH210.py:21:1: PTH210 Invalid suffix passed to `.with_suffix()` | @@ -80,7 +79,7 @@ PTH210.py:25:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 24 | path.with_suffix(u'' "json") 25 | path.with_suffix(suffix="js") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 -26 | +26 | 27 | posix_path.with_suffix(".") | = help: Add a leading dot @@ -98,7 +97,7 @@ PTH210.py:25:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` PTH210.py:27:1: PTH210 Invalid suffix passed to `.with_suffix()` | 25 | path.with_suffix(suffix="js") -26 | +26 | 27 | posix_path.with_suffix(".") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 28 | posix_path.with_suffix("py") @@ -173,7 +172,7 @@ PTH210.py:31:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 30 | posix_path.with_suffix(u'' "json") 31 | posix_path.with_suffix(suffix="js") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 -32 | +32 | 33 | pure_path.with_suffix(".") | = help: Add a leading dot @@ -191,7 +190,7 @@ PTH210.py:31:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` PTH210.py:33:1: PTH210 Invalid suffix passed to `.with_suffix()` | 31 | posix_path.with_suffix(suffix="js") -32 | +32 | 33 | pure_path.with_suffix(".") | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 34 | pure_path.with_suffix("py") @@ -266,7 +265,7 @@ PTH210.py:37:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 36 | pure_path.with_suffix(u'' "json") 37 | pure_path.with_suffix(suffix="js") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 -38 | +38 | 39 | pure_posix_path.with_suffix(".") | = help: Add a leading dot @@ -284,7 +283,7 @@ PTH210.py:37:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` PTH210.py:39:1: PTH210 Invalid suffix passed to `.with_suffix()` | 37 | pure_path.with_suffix(suffix="js") -38 | +38 | 39 | pure_posix_path.with_suffix(".") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 40 | pure_posix_path.with_suffix("py") @@ -359,7 +358,7 @@ PTH210.py:43:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 42 | pure_posix_path.with_suffix(u'' "json") 43 | pure_posix_path.with_suffix(suffix="js") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 -44 | +44 | 45 | pure_windows_path.with_suffix(".") | = help: Add a leading dot @@ -377,7 +376,7 @@ PTH210.py:43:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` PTH210.py:45:1: PTH210 Invalid suffix passed to `.with_suffix()` | 43 | pure_posix_path.with_suffix(suffix="js") -44 | +44 | 45 | pure_windows_path.with_suffix(".") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 46 | pure_windows_path.with_suffix("py") @@ -452,7 +451,7 @@ PTH210.py:49:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 48 | pure_windows_path.with_suffix(u'' "json") 49 | pure_windows_path.with_suffix(suffix="js") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 -50 | +50 | 51 | windows_path.with_suffix(".") | = help: Add a leading dot @@ -470,7 +469,7 @@ PTH210.py:49:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` PTH210.py:51:1: PTH210 Invalid suffix passed to `.with_suffix()` | 49 | pure_windows_path.with_suffix(suffix="js") -50 | +50 | 51 | windows_path.with_suffix(".") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 52 | windows_path.with_suffix("py") diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH210_PTH210_1.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH210_PTH210_1.py.snap index e394e5341f5df..9778ac85a92dd 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH210_PTH210_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH210_PTH210_1.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs -snapshot_kind: text --- PTH210_1.py:13:5: PTH210 Invalid suffix passed to `.with_suffix()` | @@ -81,7 +80,7 @@ PTH210_1.py:17:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 16 | p.with_suffix(u'' "json") 17 | p.with_suffix(suffix="js") | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 -18 | +18 | 19 | ## No errors | = help: Add a leading dot @@ -175,7 +174,7 @@ PTH210_1.py:35:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 34 | p.with_suffix(u'' "json") 35 | p.with_suffix(suffix="js") | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 -36 | +36 | 37 | ## No errors | = help: Add a leading dot @@ -269,7 +268,7 @@ PTH210_1.py:53:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 52 | p.with_suffix(u'' "json") 53 | p.with_suffix(suffix="js") | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 -54 | +54 | 55 | ## No errors | = help: Add a leading dot @@ -363,7 +362,7 @@ PTH210_1.py:71:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 70 | p.with_suffix(u'' "json") 71 | p.with_suffix(suffix="js") | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 -72 | +72 | 73 | ## No errors | = help: Add a leading dot @@ -457,7 +456,7 @@ PTH210_1.py:89:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 88 | p.with_suffix(u'' "json") 89 | p.with_suffix(suffix="js") | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 -90 | +90 | 91 | ## No errors | = help: Add a leading dot @@ -551,7 +550,7 @@ PTH210_1.py:107:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 106 | p.with_suffix(u'' "json") 107 | p.with_suffix(suffix="js") | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 -108 | +108 | 109 | ## No errors | = help: Add a leading dot diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__full_name.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__full_name.py.snap index 1bc3020743252..e0d29b06be0f9 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__full_name.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__full_name.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs -snapshot_kind: text --- full_name.py:7:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` | 5 | q = "bar" -6 | +6 | 7 | a = os.path.abspath(p) | ^^^^^^^^^^^^^^^ PTH100 8 | aa = os.chmod(p) @@ -296,7 +295,7 @@ full_name.py:37:1: PTH118 `os.sep.join()` should be replaced by `Path.joinpath() 36 | os.path.join(p, *q) 37 | os.sep.join(p, *q) | ^^^^^^^^^^^ PTH118 -38 | +38 | 39 | # https://github.com/astral-sh/ruff/issues/7620 | diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_as.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_as.py.snap index ba094e790e52d..dcf8d8a659931 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_as.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_as.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs -snapshot_kind: text --- import_as.py:7:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` | 5 | q = "bar" -6 | +6 | 7 | a = foo_p.abspath(p) | ^^^^^^^^^^^^^ PTH100 8 | aa = foo.chmod(p) diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_from.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_from.py.snap index a021b5d13b936..34fc61430d875 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_from.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_from.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs -snapshot_kind: text --- import_from.py:9:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` | 7 | q = "bar" - 8 | + 8 | 9 | a = abspath(p) | ^^^^^^^ PTH100 10 | aa = chmod(p) diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_from_as.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_from_as.py.snap index 685a57a5c4c39..7f9fc380f4b97 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_from_as.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_from_as.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs -snapshot_kind: text --- import_from_as.py:14:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` | 12 | q = "bar" -13 | +13 | 14 | a = xabspath(p) | ^^^^^^^^ PTH100 15 | aa = xchmod(p) diff --git a/crates/ruff_linter/src/rules/flynt/snapshots/ruff_linter__rules__flynt__tests__FLY002_FLY002.py.snap b/crates/ruff_linter/src/rules/flynt/snapshots/ruff_linter__rules__flynt__tests__FLY002_FLY002.py.snap index cdc4d6f996b62..9a1e06585cae8 100644 --- a/crates/ruff_linter/src/rules/flynt/snapshots/ruff_linter__rules__flynt__tests__FLY002_FLY002.py.snap +++ b/crates/ruff_linter/src/rules/flynt/snapshots/ruff_linter__rules__flynt__tests__FLY002_FLY002.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flynt/mod.rs -snapshot_kind: text --- FLY002.py:5:7: FLY002 [*] Consider `f"{a} World"` instead of string join | @@ -111,7 +110,7 @@ FLY002.py:10:7: FLY002 [*] Consider `f"{secrets.token_urlsafe()}a{secrets.token_ 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) 10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 -11 | +11 | 12 | nok1 = "x".join({"4", "5", "yee"}) # Not OK (set) | = help: Replace with `f"{secrets.token_urlsafe()}a{secrets.token_hex()}"` diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__leading_prefix.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__leading_prefix.py.snap index 19ce312aa392e..8197eb32fce86 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__leading_prefix.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__leading_prefix.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- leading_prefix.py:1:8: I001 Import block is un-sorted or un-formatted | @@ -8,7 +7,7 @@ leading_prefix.py:1:8: I001 Import block is un-sorted or un-formatted | ________^ 2 | | import os | |_________^ I001 -3 | +3 | 4 | if True: | = help: Organize imports @@ -20,7 +19,7 @@ leading_prefix.py:5:12: I001 Import block is un-sorted or un-formatted | ____________^ 6 | | import os | |_____________^ I001 -7 | +7 | 8 | if True: | = help: Organize imports @@ -31,7 +30,7 @@ leading_prefix.py:10:9: I001 Import block is un-sorted or un-formatted 9 | x = 1; \ 10 | import os | ^^^^^^^^^ I001 -11 | +11 | 12 | x = 1; \ | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_unused.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_unused.py.snap index d2e56b8e36826..4701571f2eaab 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_unused.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_unused.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- unused.py:5:8: F401 [*] `sys` imported but unused | 4 | # Unused, _not_ marked as required. 5 | import sys | ^^^ F401 -6 | +6 | 7 | # Unused, _not_ marked as required (due to the alias). | = help: Remove unused import: `sys` @@ -26,7 +25,7 @@ unused.py:8:19: F401 [*] `pathlib` imported but unused 7 | # Unused, _not_ marked as required (due to the alias). 8 | import pathlib as non_alias | ^^^^^^^^^ F401 - 9 | + 9 | 10 | # Unused, marked as required. | = help: Remove unused import: `pathlib` diff --git a/crates/ruff_linter/src/rules/mccabe/snapshots/ruff_linter__rules__mccabe__tests__max_complexity_0.snap b/crates/ruff_linter/src/rules/mccabe/snapshots/ruff_linter__rules__mccabe__tests__max_complexity_0.snap index 6e8463c24d64b..5bce1a36f6b72 100644 --- a/crates/ruff_linter/src/rules/mccabe/snapshots/ruff_linter__rules__mccabe__tests__max_complexity_0.snap +++ b/crates/ruff_linter/src/rules/mccabe/snapshots/ruff_linter__rules__mccabe__tests__max_complexity_0.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/mccabe/mod.rs -snapshot_kind: text --- C901.py:2:5: C901 `trivial` is too complex (1 > 0) | @@ -156,7 +155,7 @@ C901.py:118:17: C901 `a` is too complex (1 > 0) C901.py:121:17: C901 `b` is too complex (2 > 0) | 119 | pass -120 | +120 | 121 | def b(self, data): | ^ C901 122 | if not args: @@ -174,7 +173,7 @@ C901.py:126:17: C901 `c` is too complex (1 > 0) C901.py:129:17: C901 `error` is too complex (1 > 0) | 127 | pass -128 | +128 | 129 | def error(self, message): | ^^^^^ C901 130 | pass @@ -183,7 +182,7 @@ C901.py:129:17: C901 `error` is too complex (1 > 0) C901.py:132:17: C901 `info` is too complex (1 > 0) | 130 | pass -131 | +131 | 132 | def info(self, message): | ^^^^ C901 133 | pass @@ -192,7 +191,7 @@ C901.py:132:17: C901 `info` is too complex (1 > 0) C901.py:135:17: C901 `exception` is too complex (1 > 0) | 133 | pass -134 | +134 | 135 | def exception(self): | ^^^^^^^^^ C901 136 | pass diff --git a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-function_NPY003.py.snap b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-function_NPY003.py.snap index e7db8cbc60c88..879eb315a4038 100644 --- a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-function_NPY003.py.snap +++ b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-function_NPY003.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/numpy/mod.rs -snapshot_kind: text --- NPY003.py:4:5: NPY003 [*] `np.round_` is deprecated; use `np.round` instead | 2 | import numpy as np -3 | +3 | 4 | np.round_(np.random.rand(5, 5), 2) | ^^^^^^^^^ NPY003 5 | np.product(np.random.rand(5, 5)) @@ -106,7 +105,7 @@ NPY003.py:8:5: NPY003 [*] `np.alltrue` is deprecated; use `np.all` instead NPY003.py:14:5: NPY003 [*] `np.round_` is deprecated; use `np.round` instead | 12 | from numpy import round_, product, cumproduct, sometrue, alltrue -13 | +13 | 14 | round_(np.random.rand(5, 5), 2) | ^^^^^^ NPY003 15 | product(np.random.rand(5, 5)) diff --git a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-type-alias_NPY001.py.snap b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-type-alias_NPY001.py.snap index be73ca901ff7b..b26f49ebd01e1 100644 --- a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-type-alias_NPY001.py.snap +++ b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-type-alias_NPY001.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/numpy/mod.rs -snapshot_kind: text --- NPY001.py:6:1: NPY001 [*] Type alias `np.float` is deprecated, replace with builtin type | @@ -27,7 +26,7 @@ NPY001.py:7:1: NPY001 [*] Type alias `np.int` is deprecated, replace with builti 6 | npy.float 7 | npy.int | ^^^^^^^ NPY001 -8 | +8 | 9 | if dtype == np.object: | = help: Replace `np.int` with builtin type @@ -45,7 +44,7 @@ NPY001.py:7:1: NPY001 [*] Type alias `np.int` is deprecated, replace with builti NPY001.py:9:13: NPY001 [*] Type alias `np.object` is deprecated, replace with builtin type | 7 | npy.int - 8 | + 8 | 9 | if dtype == np.object: | ^^^^^^^^^ NPY001 10 | ... @@ -65,10 +64,10 @@ NPY001.py:9:13: NPY001 [*] Type alias `np.object` is deprecated, replace with bu NPY001.py:12:72: NPY001 [*] Type alias `np.int` is deprecated, replace with builtin type | 10 | ... -11 | +11 | 12 | result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, np.complex]) | ^^^^^^ NPY001 -13 | +13 | 14 | pdf = pd.DataFrame( | = help: Replace `np.int` with builtin type @@ -86,10 +85,10 @@ NPY001.py:12:72: NPY001 [*] Type alias `np.int` is deprecated, replace with buil NPY001.py:12:80: NPY001 [*] Type alias `np.complex` is deprecated, replace with builtin type | 10 | ... -11 | +11 | 12 | result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, np.complex]) | ^^^^^^^^^^ NPY001 -13 | +13 | 14 | pdf = pd.DataFrame( | = help: Replace `np.complex` with builtin type @@ -127,10 +126,10 @@ NPY001.py:17:11: NPY001 [*] Type alias `np.object` is deprecated, replace with b NPY001.py:20:16: NPY001 [*] Type alias `np.int` is deprecated, replace with builtin type | 18 | ) -19 | +19 | 20 | _ = arr.astype(np.int) | ^^^^^^ NPY001 -21 | +21 | 22 | # Regression test for: https://github.com/astral-sh/ruff/issues/6952 | = help: Replace `np.int` with builtin type @@ -148,7 +147,7 @@ NPY001.py:20:16: NPY001 [*] Type alias `np.int` is deprecated, replace with buil NPY001.py:25:1: NPY001 [*] Type alias `np.float` is deprecated, replace with builtin type | 23 | from numpy import float -24 | +24 | 25 | float(1) | ^^^^^ NPY001 | diff --git a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-legacy-random_NPY002.py.snap b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-legacy-random_NPY002.py.snap index 2a33936384280..150b3490bec7d 100644 --- a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-legacy-random_NPY002.py.snap +++ b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-legacy-random_NPY002.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/numpy/mod.rs -snapshot_kind: text --- NPY002.py:12:8: NPY002 Replace legacy `np.random.standard_normal` call with `np.random.Generator` | 10 | from numpy import random -11 | +11 | 12 | vals = random.standard_normal(10) | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 13 | more_vals = random.standard_normal(10) @@ -23,7 +22,7 @@ NPY002.py:13:13: NPY002 Replace legacy `np.random.standard_normal` call with `np NPY002.py:18:1: NPY002 Replace legacy `np.random.seed` call with `np.random.Generator` | 16 | import numpy -17 | +17 | 18 | numpy.random.seed() | ^^^^^^^^^^^^^^^^^ NPY002 19 | numpy.random.get_state() diff --git a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201.py.snap b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201.py.snap index 8c0a6a92e7534..124a069953c59 100644 --- a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201.py.snap +++ b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/numpy/mod.rs -snapshot_kind: text --- NPY201.py:4:5: NPY201 [*] `np.add_docstring` will be removed in NumPy 2.0. Use `numpy.lib.add_docstring` instead. | 2 | import numpy as np -3 | +3 | 4 | np.add_docstring | ^^^^^^^^^^^^^^^^ NPY201 -5 | +5 | 6 | np.add_newdoc | = help: Replace with `numpy.lib.add_docstring` @@ -27,10 +26,10 @@ NPY201.py:4:5: NPY201 [*] `np.add_docstring` will be removed in NumPy 2.0. Use ` NPY201.py:6:5: NPY201 [*] `np.add_newdoc` will be removed in NumPy 2.0. Use `numpy.lib.add_newdoc` instead. | 4 | np.add_docstring -5 | +5 | 6 | np.add_newdoc | ^^^^^^^^^^^^^ NPY201 -7 | +7 | 8 | np.add_newdoc_ufunc | = help: Replace with `numpy.lib.add_newdoc` @@ -51,30 +50,30 @@ NPY201.py:6:5: NPY201 [*] `np.add_newdoc` will be removed in NumPy 2.0. Use `num NPY201.py:8:5: NPY201 `np.add_newdoc_ufunc` will be removed in NumPy 2.0. `add_newdoc_ufunc` is an internal function. | 6 | np.add_newdoc - 7 | + 7 | 8 | np.add_newdoc_ufunc | ^^^^^^^^^^^^^^^^^^^ NPY201 - 9 | + 9 | 10 | np.asfarray([1,2,3]) | NPY201.py:10:5: NPY201 `np.asfarray` will be removed in NumPy 2.0. Use `np.asarray` with a `float` dtype instead. | 8 | np.add_newdoc_ufunc - 9 | + 9 | 10 | np.asfarray([1,2,3]) | ^^^^^^^^^^^ NPY201 -11 | +11 | 12 | np.byte_bounds(np.array([1,2,3])) | NPY201.py:12:5: NPY201 [*] `np.byte_bounds` will be removed in NumPy 2.0. Use `numpy.lib.array_utils.byte_bounds` on NumPy 2.0, or ignore this warning on earlier versions. | 10 | np.asfarray([1,2,3]) -11 | +11 | 12 | np.byte_bounds(np.array([1,2,3])) | ^^^^^^^^^^^^^^ NPY201 -13 | +13 | 14 | np.cast | = help: Replace with `numpy.lib.array_utils.byte_bounds` (requires NumPy 2.0 or greater) @@ -97,20 +96,20 @@ NPY201.py:12:5: NPY201 [*] `np.byte_bounds` will be removed in NumPy 2.0. Use `n NPY201.py:14:5: NPY201 `np.cast` will be removed in NumPy 2.0. Use `np.asarray(arr, dtype=dtype)` instead. | 12 | np.byte_bounds(np.array([1,2,3])) -13 | +13 | 14 | np.cast | ^^^^^^^ NPY201 -15 | +15 | 16 | np.cfloat(12+34j) | NPY201.py:16:5: NPY201 [*] `np.cfloat` will be removed in NumPy 2.0. Use `numpy.complex128` instead. | 14 | np.cast -15 | +15 | 16 | np.cfloat(12+34j) | ^^^^^^^^^ NPY201 -17 | +17 | 18 | np.clongfloat(12+34j) | = help: Replace with `numpy.complex128` @@ -128,10 +127,10 @@ NPY201.py:16:5: NPY201 [*] `np.cfloat` will be removed in NumPy 2.0. Use `numpy. NPY201.py:18:5: NPY201 [*] `np.clongfloat` will be removed in NumPy 2.0. Use `numpy.clongdouble` instead. | 16 | np.cfloat(12+34j) -17 | +17 | 18 | np.clongfloat(12+34j) | ^^^^^^^^^^^^^ NPY201 -19 | +19 | 20 | np.compat | = help: Replace with `numpy.clongdouble` @@ -149,20 +148,20 @@ NPY201.py:18:5: NPY201 [*] `np.clongfloat` will be removed in NumPy 2.0. Use `nu NPY201.py:20:5: NPY201 `np.compat` will be removed in NumPy 2.0. Python 2 is no longer supported. | 18 | np.clongfloat(12+34j) -19 | +19 | 20 | np.compat | ^^^^^^^^^ NPY201 -21 | +21 | 22 | np.complex_(12+34j) | NPY201.py:22:5: NPY201 [*] `np.complex_` will be removed in NumPy 2.0. Use `numpy.complex128` instead. | 20 | np.compat -21 | +21 | 22 | np.complex_(12+34j) | ^^^^^^^^^^^ NPY201 -23 | +23 | 24 | np.DataSource | = help: Replace with `numpy.complex128` @@ -180,10 +179,10 @@ NPY201.py:22:5: NPY201 [*] `np.complex_` will be removed in NumPy 2.0. Use `nump NPY201.py:24:5: NPY201 [*] `np.DataSource` will be removed in NumPy 2.0. Use `numpy.lib.npyio.DataSource` instead. | 22 | np.complex_(12+34j) -23 | +23 | 24 | np.DataSource | ^^^^^^^^^^^^^ NPY201 -25 | +25 | 26 | np.deprecate | = help: Replace with `numpy.lib.npyio.DataSource` @@ -206,70 +205,70 @@ NPY201.py:24:5: NPY201 [*] `np.DataSource` will be removed in NumPy 2.0. Use `nu NPY201.py:26:5: NPY201 `np.deprecate` will be removed in NumPy 2.0. Emit `DeprecationWarning` with `warnings.warn` directly, or use `typing.deprecated`. | 24 | np.DataSource -25 | +25 | 26 | np.deprecate | ^^^^^^^^^^^^ NPY201 -27 | +27 | 28 | np.deprecate_with_doc | NPY201.py:28:5: NPY201 `np.deprecate_with_doc` will be removed in NumPy 2.0. Emit `DeprecationWarning` with `warnings.warn` directly, or use `typing.deprecated`. | 26 | np.deprecate -27 | +27 | 28 | np.deprecate_with_doc | ^^^^^^^^^^^^^^^^^^^^^ NPY201 -29 | +29 | 30 | np.disp(10) | NPY201.py:30:5: NPY201 `np.disp` will be removed in NumPy 2.0. Use a dedicated print function instead. | 28 | np.deprecate_with_doc -29 | +29 | 30 | np.disp(10) | ^^^^^^^ NPY201 -31 | +31 | 32 | np.fastCopyAndTranspose | NPY201.py:32:5: NPY201 `np.fastCopyAndTranspose` will be removed in NumPy 2.0. Use `arr.T.copy()` instead. | 30 | np.disp(10) -31 | +31 | 32 | np.fastCopyAndTranspose | ^^^^^^^^^^^^^^^^^^^^^^^ NPY201 -33 | +33 | 34 | np.find_common_type | NPY201.py:34:5: NPY201 `np.find_common_type` will be removed in NumPy 2.0. Use `numpy.promote_types` or `numpy.result_type` instead. To achieve semantics for the `scalar_types` argument, use `numpy.result_type` and pass the Python values `0`, `0.0`, or `0j`. | 32 | np.fastCopyAndTranspose -33 | +33 | 34 | np.find_common_type | ^^^^^^^^^^^^^^^^^^^ NPY201 -35 | +35 | 36 | np.get_array_wrap | NPY201.py:36:5: NPY201 `np.get_array_wrap` will be removed without replacement in NumPy 2.0 | 34 | np.find_common_type -35 | +35 | 36 | np.get_array_wrap | ^^^^^^^^^^^^^^^^^ NPY201 -37 | +37 | 38 | np.float_ | NPY201.py:38:5: NPY201 [*] `np.float_` will be removed in NumPy 2.0. Use `numpy.float64` instead. | 36 | np.get_array_wrap -37 | +37 | 38 | np.float_ | ^^^^^^^^^ NPY201 -39 | +39 | 40 | np.geterrobj | = help: Replace with `numpy.float64` @@ -287,20 +286,20 @@ NPY201.py:38:5: NPY201 [*] `np.float_` will be removed in NumPy 2.0. Use `numpy. NPY201.py:40:5: NPY201 `np.geterrobj` will be removed in NumPy 2.0. Use the `np.errstate` context manager instead. | 38 | np.float_ -39 | +39 | 40 | np.geterrobj | ^^^^^^^^^^^^ NPY201 -41 | +41 | 42 | np.Inf | NPY201.py:42:5: NPY201 [*] `np.Inf` will be removed in NumPy 2.0. Use `numpy.inf` instead. | 40 | np.geterrobj -41 | +41 | 42 | np.Inf | ^^^^^^ NPY201 -43 | +43 | 44 | np.Infinity | = help: Replace with `numpy.inf` @@ -318,10 +317,10 @@ NPY201.py:42:5: NPY201 [*] `np.Inf` will be removed in NumPy 2.0. Use `numpy.inf NPY201.py:44:5: NPY201 [*] `np.Infinity` will be removed in NumPy 2.0. Use `numpy.inf` instead. | 42 | np.Inf -43 | +43 | 44 | np.Infinity | ^^^^^^^^^^^ NPY201 -45 | +45 | 46 | np.infty | = help: Replace with `numpy.inf` @@ -339,10 +338,10 @@ NPY201.py:44:5: NPY201 [*] `np.Infinity` will be removed in NumPy 2.0. Use `nump NPY201.py:46:5: NPY201 [*] `np.infty` will be removed in NumPy 2.0. Use `numpy.inf` instead. | 44 | np.Infinity -45 | +45 | 46 | np.infty | ^^^^^^^^ NPY201 -47 | +47 | 48 | np.issctype | = help: Replace with `numpy.inf` @@ -360,20 +359,20 @@ NPY201.py:46:5: NPY201 [*] `np.infty` will be removed in NumPy 2.0. Use `numpy.i NPY201.py:48:5: NPY201 `np.issctype` will be removed without replacement in NumPy 2.0 | 46 | np.infty -47 | +47 | 48 | np.issctype | ^^^^^^^^^^^ NPY201 -49 | +49 | 50 | np.issubclass_(np.int32, np.integer) | NPY201.py:50:5: NPY201 [*] `np.issubclass_` will be removed in NumPy 2.0. Use `issubclass` instead. | 48 | np.issctype -49 | +49 | 50 | np.issubclass_(np.int32, np.integer) | ^^^^^^^^^^^^^^ NPY201 -51 | +51 | 52 | np.issubsctype | = help: Replace with `issubclass` @@ -391,10 +390,10 @@ NPY201.py:50:5: NPY201 [*] `np.issubclass_` will be removed in NumPy 2.0. Use `i NPY201.py:52:5: NPY201 [*] `np.issubsctype` will be removed in NumPy 2.0. Use `numpy.issubdtype` instead. | 50 | np.issubclass_(np.int32, np.integer) -51 | +51 | 52 | np.issubsctype | ^^^^^^^^^^^^^^ NPY201 -53 | +53 | 54 | np.mat | = help: Replace with `numpy.issubdtype` @@ -412,10 +411,10 @@ NPY201.py:52:5: NPY201 [*] `np.issubsctype` will be removed in NumPy 2.0. Use `n NPY201.py:54:5: NPY201 [*] `np.mat` will be removed in NumPy 2.0. Use `numpy.asmatrix` instead. | 52 | np.issubsctype -53 | +53 | 54 | np.mat | ^^^^^^ NPY201 -55 | +55 | 56 | np.maximum_sctype | = help: Replace with `numpy.asmatrix` @@ -433,20 +432,20 @@ NPY201.py:54:5: NPY201 [*] `np.mat` will be removed in NumPy 2.0. Use `numpy.asm NPY201.py:56:5: NPY201 `np.maximum_sctype` will be removed without replacement in NumPy 2.0 | 54 | np.mat -55 | +55 | 56 | np.maximum_sctype | ^^^^^^^^^^^^^^^^^ NPY201 -57 | +57 | 58 | np.NaN | NPY201.py:58:5: NPY201 [*] `np.NaN` will be removed in NumPy 2.0. Use `numpy.nan` instead. | 56 | np.maximum_sctype -57 | +57 | 58 | np.NaN | ^^^^^^ NPY201 -59 | +59 | 60 | np.nbytes[np.int64] | = help: Replace with `numpy.nan` @@ -464,20 +463,20 @@ NPY201.py:58:5: NPY201 [*] `np.NaN` will be removed in NumPy 2.0. Use `numpy.nan NPY201.py:60:5: NPY201 `np.nbytes` will be removed in NumPy 2.0. Use `np.dtype().itemsize` instead. | 58 | np.NaN -59 | +59 | 60 | np.nbytes[np.int64] | ^^^^^^^^^ NPY201 -61 | +61 | 62 | np.NINF | NPY201.py:62:5: NPY201 [*] `np.NINF` will be removed in NumPy 2.0. Use `-np.inf` instead. | 60 | np.nbytes[np.int64] -61 | +61 | 62 | np.NINF | ^^^^^^^ NPY201 -63 | +63 | 64 | np.NZERO | = help: Replace with `-np.inf` @@ -495,10 +494,10 @@ NPY201.py:62:5: NPY201 [*] `np.NINF` will be removed in NumPy 2.0. Use `-np.inf` NPY201.py:64:5: NPY201 [*] `np.NZERO` will be removed in NumPy 2.0. Use `-0.0` instead. | 62 | np.NINF -63 | +63 | 64 | np.NZERO | ^^^^^^^^ NPY201 -65 | +65 | 66 | np.longcomplex(12+34j) | = help: Replace with `-0.0` @@ -516,10 +515,10 @@ NPY201.py:64:5: NPY201 [*] `np.NZERO` will be removed in NumPy 2.0. Use `-0.0` i NPY201.py:66:5: NPY201 [*] `np.longcomplex` will be removed in NumPy 2.0. Use `numpy.clongdouble` instead. | 64 | np.NZERO -65 | +65 | 66 | np.longcomplex(12+34j) | ^^^^^^^^^^^^^^ NPY201 -67 | +67 | 68 | np.longfloat(12+34j) | = help: Replace with `numpy.clongdouble` @@ -537,10 +536,10 @@ NPY201.py:66:5: NPY201 [*] `np.longcomplex` will be removed in NumPy 2.0. Use `n NPY201.py:68:5: NPY201 [*] `np.longfloat` will be removed in NumPy 2.0. Use `numpy.longdouble` instead. | 66 | np.longcomplex(12+34j) -67 | +67 | 68 | np.longfloat(12+34j) | ^^^^^^^^^^^^ NPY201 -69 | +69 | 70 | np.lookfor | = help: Replace with `numpy.longdouble` @@ -558,20 +557,20 @@ NPY201.py:68:5: NPY201 [*] `np.longfloat` will be removed in NumPy 2.0. Use `num NPY201.py:70:5: NPY201 `np.lookfor` will be removed in NumPy 2.0. Search NumPy’s documentation directly. | 68 | np.longfloat(12+34j) -69 | +69 | 70 | np.lookfor | ^^^^^^^^^^ NPY201 -71 | +71 | 72 | np.NAN | NPY201.py:72:5: NPY201 [*] `np.NAN` will be removed in NumPy 2.0. Use `numpy.nan` instead. | 70 | np.lookfor -71 | +71 | 72 | np.NAN | ^^^^^^ NPY201 -73 | +73 | 74 | try: | = help: Replace with `numpy.nan` diff --git a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_2.py.snap b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_2.py.snap index bf39ffc353f3f..9350fd8d19896 100644 --- a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_2.py.snap +++ b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_2.py.snap @@ -1,24 +1,23 @@ --- source: crates/ruff_linter/src/rules/numpy/mod.rs -snapshot_kind: text --- NPY201_2.py:4:5: NPY201 `np.obj2sctype` will be removed without replacement in NumPy 2.0 | 2 | import numpy as np -3 | +3 | 4 | np.obj2sctype(int) | ^^^^^^^^^^^^^ NPY201 -5 | +5 | 6 | np.PINF | NPY201_2.py:6:5: NPY201 [*] `np.PINF` will be removed in NumPy 2.0. Use `numpy.inf` instead. | 4 | np.obj2sctype(int) -5 | +5 | 6 | np.PINF | ^^^^^^^ NPY201 -7 | +7 | 8 | np.PZERO | = help: Replace with `numpy.inf` @@ -36,10 +35,10 @@ NPY201_2.py:6:5: NPY201 [*] `np.PINF` will be removed in NumPy 2.0. Use `numpy.i NPY201_2.py:8:5: NPY201 [*] `np.PZERO` will be removed in NumPy 2.0. Use `0.0` instead. | 6 | np.PINF - 7 | + 7 | 8 | np.PZERO | ^^^^^^^^ NPY201 - 9 | + 9 | 10 | np.recfromcsv | = help: Replace with `0.0` @@ -57,30 +56,30 @@ NPY201_2.py:8:5: NPY201 [*] `np.PZERO` will be removed in NumPy 2.0. Use `0.0` i NPY201_2.py:10:5: NPY201 `np.recfromcsv` will be removed in NumPy 2.0. Use `np.genfromtxt` with comma delimiter instead. | 8 | np.PZERO - 9 | + 9 | 10 | np.recfromcsv | ^^^^^^^^^^^^^ NPY201 -11 | +11 | 12 | np.recfromtxt | NPY201_2.py:12:5: NPY201 `np.recfromtxt` will be removed in NumPy 2.0. Use `np.genfromtxt` instead. | 10 | np.recfromcsv -11 | +11 | 12 | np.recfromtxt | ^^^^^^^^^^^^^ NPY201 -13 | +13 | 14 | np.round_(12.34) | NPY201_2.py:14:5: NPY201 [*] `np.round_` will be removed in NumPy 2.0. Use `numpy.round` instead. | 12 | np.recfromtxt -13 | +13 | 14 | np.round_(12.34) | ^^^^^^^^^ NPY201 -15 | +15 | 16 | np.safe_eval | = help: Replace with `numpy.round` @@ -98,10 +97,10 @@ NPY201_2.py:14:5: NPY201 [*] `np.round_` will be removed in NumPy 2.0. Use `nump NPY201_2.py:16:5: NPY201 [*] `np.safe_eval` will be removed in NumPy 2.0. Use `ast.literal_eval` instead. | 14 | np.round_(12.34) -15 | +15 | 16 | np.safe_eval | ^^^^^^^^^^^^ NPY201 -17 | +17 | 18 | np.sctype2char | = help: Replace with `ast.literal_eval` @@ -124,50 +123,50 @@ NPY201_2.py:16:5: NPY201 [*] `np.safe_eval` will be removed in NumPy 2.0. Use `a NPY201_2.py:18:5: NPY201 `np.sctype2char` will be removed without replacement in NumPy 2.0 | 16 | np.safe_eval -17 | +17 | 18 | np.sctype2char | ^^^^^^^^^^^^^^ NPY201 -19 | +19 | 20 | np.sctypes | NPY201_2.py:20:5: NPY201 `np.sctypes` will be removed without replacement in NumPy 2.0 | 18 | np.sctype2char -19 | +19 | 20 | np.sctypes | ^^^^^^^^^^ NPY201 -21 | +21 | 22 | np.seterrobj | NPY201_2.py:22:5: NPY201 `np.seterrobj` will be removed in NumPy 2.0. Use the `np.errstate` context manager instead. | 20 | np.sctypes -21 | +21 | 22 | np.seterrobj | ^^^^^^^^^^^^ NPY201 -23 | +23 | 24 | np.set_numeric_ops | NPY201_2.py:26:5: NPY201 `np.set_string_function` will be removed in NumPy 2.0. Use `np.set_printoptions` for custom printing of NumPy objects. | 24 | np.set_numeric_ops -25 | +25 | 26 | np.set_string_function | ^^^^^^^^^^^^^^^^^^^^^^ NPY201 -27 | +27 | 28 | np.singlecomplex(12+1j) | NPY201_2.py:28:5: NPY201 [*] `np.singlecomplex` will be removed in NumPy 2.0. Use `numpy.complex64` instead. | 26 | np.set_string_function -27 | +27 | 28 | np.singlecomplex(12+1j) | ^^^^^^^^^^^^^^^^ NPY201 -29 | +29 | 30 | np.string_("asdf") | = help: Replace with `numpy.complex64` @@ -185,10 +184,10 @@ NPY201_2.py:28:5: NPY201 [*] `np.singlecomplex` will be removed in NumPy 2.0. Us NPY201_2.py:30:5: NPY201 [*] `np.string_` will be removed in NumPy 2.0. Use `numpy.bytes_` instead. | 28 | np.singlecomplex(12+1j) -29 | +29 | 30 | np.string_("asdf") | ^^^^^^^^^^ NPY201 -31 | +31 | 32 | np.source | = help: Replace with `numpy.bytes_` @@ -206,10 +205,10 @@ NPY201_2.py:30:5: NPY201 [*] `np.string_` will be removed in NumPy 2.0. Use `num NPY201_2.py:32:5: NPY201 [*] `np.source` will be removed in NumPy 2.0. Use `inspect.getsource` instead. | 30 | np.string_("asdf") -31 | +31 | 32 | np.source | ^^^^^^^^^ NPY201 -33 | +33 | 34 | np.tracemalloc_domain | = help: Replace with `inspect.getsource` @@ -232,10 +231,10 @@ NPY201_2.py:32:5: NPY201 [*] `np.source` will be removed in NumPy 2.0. Use `insp NPY201_2.py:34:5: NPY201 [*] `np.tracemalloc_domain` will be removed in NumPy 2.0. Use `numpy.lib.tracemalloc_domain` instead. | 32 | np.source -33 | +33 | 34 | np.tracemalloc_domain | ^^^^^^^^^^^^^^^^^^^^^ NPY201 -35 | +35 | 36 | np.unicode_("asf") | = help: Replace with `numpy.lib.tracemalloc_domain` @@ -258,10 +257,10 @@ NPY201_2.py:34:5: NPY201 [*] `np.tracemalloc_domain` will be removed in NumPy 2. NPY201_2.py:36:5: NPY201 [*] `np.unicode_` will be removed in NumPy 2.0. Use `numpy.str_` instead. | 34 | np.tracemalloc_domain -35 | +35 | 36 | np.unicode_("asf") | ^^^^^^^^^^^ NPY201 -37 | +37 | 38 | np.who() | = help: Replace with `numpy.str_` @@ -279,20 +278,20 @@ NPY201_2.py:36:5: NPY201 [*] `np.unicode_` will be removed in NumPy 2.0. Use `nu NPY201_2.py:38:5: NPY201 `np.who` will be removed in NumPy 2.0. Use an IDE variable explorer or `locals()` instead. | 36 | np.unicode_("asf") -37 | +37 | 38 | np.who() | ^^^^^^ NPY201 -39 | +39 | 40 | np.row_stack(([1,2], [3,4])) | NPY201_2.py:40:5: NPY201 [*] `np.row_stack` will be removed in NumPy 2.0. Use `numpy.vstack` instead. | 38 | np.who() -39 | +39 | 40 | np.row_stack(([1,2], [3,4])) | ^^^^^^^^^^^^ NPY201 -41 | +41 | 42 | np.alltrue([True, True]) | = help: Replace with `numpy.vstack` @@ -310,10 +309,10 @@ NPY201_2.py:40:5: NPY201 [*] `np.row_stack` will be removed in NumPy 2.0. Use `n NPY201_2.py:42:5: NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `numpy.all` instead. | 40 | np.row_stack(([1,2], [3,4])) -41 | +41 | 42 | np.alltrue([True, True]) | ^^^^^^^^^^ NPY201 -43 | +43 | 44 | np.sometrue([True, False]) | = help: Replace with `numpy.all` @@ -331,10 +330,10 @@ NPY201_2.py:42:5: NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `num NPY201_2.py:44:5: NPY201 [*] `np.sometrue` will be removed in NumPy 2.0. Use `numpy.any` instead. | 42 | np.alltrue([True, True]) -43 | +43 | 44 | np.sometrue([True, False]) | ^^^^^^^^^^^ NPY201 -45 | +45 | 46 | np.cumproduct([1, 2, 3]) | = help: Replace with `numpy.any` @@ -352,10 +351,10 @@ NPY201_2.py:44:5: NPY201 [*] `np.sometrue` will be removed in NumPy 2.0. Use `nu NPY201_2.py:46:5: NPY201 [*] `np.cumproduct` will be removed in NumPy 2.0. Use `numpy.cumprod` instead. | 44 | np.sometrue([True, False]) -45 | +45 | 46 | np.cumproduct([1, 2, 3]) | ^^^^^^^^^^^^^ NPY201 -47 | +47 | 48 | np.product([1, 2, 3]) | = help: Replace with `numpy.cumprod` @@ -373,10 +372,10 @@ NPY201_2.py:46:5: NPY201 [*] `np.cumproduct` will be removed in NumPy 2.0. Use ` NPY201_2.py:48:5: NPY201 [*] `np.product` will be removed in NumPy 2.0. Use `numpy.prod` instead. | 46 | np.cumproduct([1, 2, 3]) -47 | +47 | 48 | np.product([1, 2, 3]) | ^^^^^^^^^^ NPY201 -49 | +49 | 50 | np.trapz([1, 2, 3]) | = help: Replace with `numpy.prod` @@ -394,10 +393,10 @@ NPY201_2.py:48:5: NPY201 [*] `np.product` will be removed in NumPy 2.0. Use `num NPY201_2.py:50:5: NPY201 [*] `np.trapz` will be removed in NumPy 2.0. Use `numpy.trapezoid` on NumPy 2.0, or ignore this warning on earlier versions. | 48 | np.product([1, 2, 3]) -49 | +49 | 50 | np.trapz([1, 2, 3]) | ^^^^^^^^ NPY201 -51 | +51 | 52 | np.in1d([1, 2], [1, 3, 5]) | = help: Replace with `numpy.trapezoid` (requires NumPy 2.0 or greater) @@ -415,10 +414,10 @@ NPY201_2.py:50:5: NPY201 [*] `np.trapz` will be removed in NumPy 2.0. Use `numpy NPY201_2.py:52:5: NPY201 [*] `np.in1d` will be removed in NumPy 2.0. Use `numpy.isin` instead. | 50 | np.trapz([1, 2, 3]) -51 | +51 | 52 | np.in1d([1, 2], [1, 3, 5]) | ^^^^^^^ NPY201 -53 | +53 | 54 | np.AxisError | = help: Replace with `numpy.isin` @@ -436,10 +435,10 @@ NPY201_2.py:52:5: NPY201 [*] `np.in1d` will be removed in NumPy 2.0. Use `numpy. NPY201_2.py:54:5: NPY201 [*] `np.AxisError` will be removed in NumPy 2.0. Use `numpy.exceptions.AxisError` instead. | 52 | np.in1d([1, 2], [1, 3, 5]) -53 | +53 | 54 | np.AxisError | ^^^^^^^^^^^^ NPY201 -55 | +55 | 56 | np.ComplexWarning | = help: Replace with `numpy.exceptions.AxisError` @@ -462,10 +461,10 @@ NPY201_2.py:54:5: NPY201 [*] `np.AxisError` will be removed in NumPy 2.0. Use `n NPY201_2.py:56:5: NPY201 [*] `np.ComplexWarning` will be removed in NumPy 2.0. Use `numpy.exceptions.ComplexWarning` instead. | 54 | np.AxisError -55 | +55 | 56 | np.ComplexWarning | ^^^^^^^^^^^^^^^^^ NPY201 -57 | +57 | 58 | np.compare_chararrays | = help: Replace with `numpy.exceptions.ComplexWarning` @@ -488,10 +487,10 @@ NPY201_2.py:56:5: NPY201 [*] `np.ComplexWarning` will be removed in NumPy 2.0. U NPY201_2.py:58:5: NPY201 [*] `np.compare_chararrays` will be removed in NumPy 2.0. Use `numpy.char.compare_chararrays` instead. | 56 | np.ComplexWarning -57 | +57 | 58 | np.compare_chararrays | ^^^^^^^^^^^^^^^^^^^^^ NPY201 -59 | +59 | 60 | try: | = help: Replace with `numpy.char.compare_chararrays` @@ -517,7 +516,7 @@ NPY201_2.py:63:9: NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `num 62 | except TypeError: 63 | np.alltrue([True, True]) # Should emit a warning here (`except TypeError`, not `except AttributeError`) | ^^^^^^^^^^ NPY201 -64 | +64 | 65 | try: | = help: Replace with `numpy.all` diff --git a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_3.py.snap b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_3.py.snap index 57e91dfff46ae..bcdea9554d9dd 100644 --- a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_3.py.snap +++ b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_3.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/numpy/mod.rs -snapshot_kind: text --- NPY201_3.py:4:5: NPY201 [*] `np.DTypePromotionError` will be removed in NumPy 2.0. Use `numpy.exceptions.DTypePromotionError` instead. | 2 | import numpy as np -3 | +3 | 4 | np.DTypePromotionError | ^^^^^^^^^^^^^^^^^^^^^^ NPY201 -5 | +5 | 6 | np.ModuleDeprecationWarning | = help: Replace with `numpy.exceptions.DTypePromotionError` @@ -27,10 +26,10 @@ NPY201_3.py:4:5: NPY201 [*] `np.DTypePromotionError` will be removed in NumPy 2. NPY201_3.py:6:5: NPY201 [*] `np.ModuleDeprecationWarning` will be removed in NumPy 2.0. Use `numpy.exceptions.ModuleDeprecationWarning` instead. | 4 | np.DTypePromotionError -5 | +5 | 6 | np.ModuleDeprecationWarning | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY201 -7 | +7 | 8 | np.RankWarning | = help: Replace with `numpy.exceptions.ModuleDeprecationWarning` @@ -51,10 +50,10 @@ NPY201_3.py:6:5: NPY201 [*] `np.ModuleDeprecationWarning` will be removed in Num NPY201_3.py:8:5: NPY201 [*] `np.RankWarning` will be removed in NumPy 2.0. Use `numpy.exceptions.RankWarning` on NumPy 2.0, or ignore this warning on earlier versions. | 6 | np.ModuleDeprecationWarning - 7 | + 7 | 8 | np.RankWarning | ^^^^^^^^^^^^^^ NPY201 - 9 | + 9 | 10 | np.TooHardError | = help: Replace with `numpy.exceptions.RankWarning` (requires NumPy 2.0 or greater) @@ -77,10 +76,10 @@ NPY201_3.py:8:5: NPY201 [*] `np.RankWarning` will be removed in NumPy 2.0. Use ` NPY201_3.py:10:5: NPY201 [*] `np.TooHardError` will be removed in NumPy 2.0. Use `numpy.exceptions.TooHardError` instead. | 8 | np.RankWarning - 9 | + 9 | 10 | np.TooHardError | ^^^^^^^^^^^^^^^ NPY201 -11 | +11 | 12 | np.VisibleDeprecationWarning | = help: Replace with `numpy.exceptions.TooHardError` @@ -103,10 +102,10 @@ NPY201_3.py:10:5: NPY201 [*] `np.TooHardError` will be removed in NumPy 2.0. Use NPY201_3.py:12:5: NPY201 [*] `np.VisibleDeprecationWarning` will be removed in NumPy 2.0. Use `numpy.exceptions.VisibleDeprecationWarning` instead. | 10 | np.TooHardError -11 | +11 | 12 | np.VisibleDeprecationWarning | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY201 -13 | +13 | 14 | np.chararray | = help: Replace with `numpy.exceptions.VisibleDeprecationWarning` @@ -129,10 +128,10 @@ NPY201_3.py:12:5: NPY201 [*] `np.VisibleDeprecationWarning` will be removed in N NPY201_3.py:14:5: NPY201 [*] `np.chararray` will be removed in NumPy 2.0. Use `numpy.char.chararray` instead. | 12 | np.VisibleDeprecationWarning -13 | +13 | 14 | np.chararray | ^^^^^^^^^^^^ NPY201 -15 | +15 | 16 | np.format_parser | = help: Replace with `numpy.char.chararray` @@ -154,7 +153,7 @@ NPY201_3.py:14:5: NPY201 [*] `np.chararray` will be removed in NumPy 2.0. Use `n NPY201_3.py:16:5: NPY201 [*] `np.format_parser` will be removed in NumPy 2.0. Use `numpy.rec.format_parser` instead. | 14 | np.chararray -15 | +15 | 16 | np.format_parser | ^^^^^^^^^^^^^^^^ NPY201 | diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_PD002.py.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_PD002.py.snap index b1bc23c5d7250..1d9c8f3df547a 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_PD002.py.snap +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_PD002.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/pandas_vet/mod.rs -snapshot_kind: text --- PD002.py:5:23: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior | 3 | x = pd.DataFrame() -4 | +4 | 5 | x.drop(["a"], axis=1, inplace=True) | ^^^^^^^^^^^^ PD002 -6 | +6 | 7 | x.y.drop(["a"], axis=1, inplace=True) | = help: Assign to variable; remove `inplace` arg @@ -26,10 +25,10 @@ PD002.py:5:23: PD002 [*] `inplace=True` should be avoided; it has inconsistent b PD002.py:7:25: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior | 5 | x.drop(["a"], axis=1, inplace=True) -6 | +6 | 7 | x.y.drop(["a"], axis=1, inplace=True) | ^^^^^^^^^^^^ PD002 -8 | +8 | 9 | x["y"].drop(["a"], axis=1, inplace=True) | = help: Assign to variable; remove `inplace` arg @@ -47,10 +46,10 @@ PD002.py:7:25: PD002 [*] `inplace=True` should be avoided; it has inconsistent b PD002.py:9:28: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior | 7 | x.y.drop(["a"], axis=1, inplace=True) - 8 | + 8 | 9 | x["y"].drop(["a"], axis=1, inplace=True) | ^^^^^^^^^^^^ PD002 -10 | +10 | 11 | x.drop( | = help: Assign to variable; remove `inplace` arg @@ -111,7 +110,7 @@ PD002.py:19:9: PD002 [*] `inplace=True` should be avoided; it has inconsistent b PD002.py:24:33: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior | 22 | ) -23 | +23 | 24 | x.drop(["a"], axis=1, **kwargs, inplace=True) | ^^^^^^^^^^^^ PD002 25 | x.drop(["a"], axis=1, inplace=True, **kwargs) @@ -144,7 +143,7 @@ PD002.py:26:25: PD002 `inplace=True` should be avoided; it has inconsistent beha 25 | x.drop(["a"], axis=1, inplace=True, **kwargs) 26 | f(x.drop(["a"], axis=1, inplace=True)) | ^^^^^^^^^^^^ PD002 -27 | +27 | 28 | x.apply(lambda x: x.sort_values("a", inplace=True)) | = help: Assign to variable; remove `inplace` arg @@ -152,7 +151,7 @@ PD002.py:26:25: PD002 `inplace=True` should be avoided; it has inconsistent beha PD002.py:28:38: PD002 `inplace=True` should be avoided; it has inconsistent behavior | 26 | f(x.drop(["a"], axis=1, inplace=True)) -27 | +27 | 28 | x.apply(lambda x: x.sort_values("a", inplace=True)) | ^^^^^^^^^^^^ PD002 29 | import torch @@ -162,10 +161,10 @@ PD002.py:28:38: PD002 `inplace=True` should be avoided; it has inconsistent beha PD002.py:33:24: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior | 31 | torch.m.ReLU(inplace=True) # safe because this isn't a pandas call -32 | +32 | 33 | (x.drop(["a"], axis=1, inplace=True)) | ^^^^^^^^^^^^ PD002 -34 | +34 | 35 | # This method doesn't take exist in Pandas, so ignore it. | = help: Assign to variable; remove `inplace` arg diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD012_pandas_use_of_dot_read_table.py.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD012_pandas_use_of_dot_read_table.py.snap index 82ea7d58cbd55..a9f1da574b807 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD012_pandas_use_of_dot_read_table.py.snap +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD012_pandas_use_of_dot_read_table.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pandas_vet/mod.rs -snapshot_kind: text --- pandas_use_of_dot_read_table.py:4:6: PD012 Use `.read_csv` instead of `.read_table` to read CSV files | @@ -36,6 +35,6 @@ pandas_use_of_dot_read_table.py:8:6: PD012 Use `.read_csv` instead of `.read_tab 7 | df = pd.read_table(filename, sep=",") 8 | df = pd.read_table(filename, sep=",", header=0) | ^^^^^^^^^^^^^ PD012 - 9 | + 9 | 10 | # Non-errors. | diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD101_PD101.py.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD101_PD101.py.snap index 34df62827876d..ec4c1808b5a88 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD101_PD101.py.snap +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD101_PD101.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pandas_vet/mod.rs -snapshot_kind: text --- PD101.py:7:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient | @@ -116,6 +115,6 @@ PD101.py:18:1: PD101 Using `series.nunique()` for checking that a series is cons 17 | data.dropna().nunique() == 1 18 | data[data.notnull()].nunique() == 1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 -19 | +19 | 20 | # No violation of this rule | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N802_N802.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N802_N802.py.snap index f15dd43444948..f2e5311d5e39f 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N802_N802.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N802_N802.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N802.py:4:5: N802 Function name `Bad` should be lowercase | @@ -33,7 +32,7 @@ N802.py:16:5: N802 Function name `BAD_FUNC` should be lowercase N802.py:40:9: N802 Function name `testTest` should be lowercase | 38 | return super().tearDown() -39 | +39 | 40 | def testTest(self): | ^^^^^^^^ N802 41 | assert True diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N804_N804.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N804_N804.py.snap index 992353a4c616b..140631d9ff4c2 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N804_N804.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N804_N804.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N804.py:30:27: N804 [*] First argument of a class method should be named `cls` | 28 | ... -29 | +29 | 30 | def __init_subclass__(self, default_name, **kwargs): | ^^^^ N804 31 | ... @@ -72,7 +71,7 @@ N804.py:54:25: N804 First argument of a class method should be named `cls` N804.py:57:34: N804 First argument of a class method should be named `cls` | 55 | pass -56 | +56 | 57 | def cls_as_pos_only_argument(this, cls, /): | ^^^^ N804 58 | pass @@ -82,7 +81,7 @@ N804.py:57:34: N804 First argument of a class method should be named `cls` N804.py:60:33: N804 First argument of a class method should be named `cls` | 58 | pass -59 | +59 | 60 | def cls_as_kw_only_argument(this, *, cls): | ^^^^ N804 61 | pass @@ -92,7 +91,7 @@ N804.py:60:33: N804 First argument of a class method should be named `cls` N804.py:63:23: N804 First argument of a class method should be named `cls` | 61 | pass -62 | +62 | 63 | def cls_as_varags(this, *cls): | ^^^^ N804 64 | pass @@ -102,7 +101,7 @@ N804.py:63:23: N804 First argument of a class method should be named `cls` N804.py:66:23: N804 First argument of a class method should be named `cls` | 64 | pass -65 | +65 | 66 | def cls_as_kwargs(this, **cls): | ^^^^ N804 67 | pass @@ -136,7 +135,7 @@ N804.py:70:20: N804 [*] First argument of a class method should be named `cls` N804.py:74:20: N804 [*] First argument of a class method should be named `cls` | 72 | this -73 | +73 | 74 | def bad_method(this): | ^^^^ N804 75 | self = this diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N805_N805.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N805_N805.py.snap index 59574238ce110..89d578bc7f186 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N805_N805.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N805_N805.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N805.py:7:20: N805 [*] First argument of a method should be named `self` | @@ -81,7 +80,7 @@ N805.py:34:15: N805 [*] First argument of a method should be named `self` N805.py:63:29: N805 [*] First argument of a method should be named `self` | 61 | pass -62 | +62 | 63 | def bad_method_pos_only(this, blah, /, something: str): | ^^^^ N805 64 | pass @@ -187,7 +186,7 @@ N805.py:98:26: N805 First argument of a method should be named `self` N805.py:101:35: N805 First argument of a method should be named `self` | 99 | pass -100 | +100 | 101 | def self_as_pos_only_argument(this, self, /): | ^^^^ N805 102 | pass @@ -197,7 +196,7 @@ N805.py:101:35: N805 First argument of a method should be named `self` N805.py:104:34: N805 First argument of a method should be named `self` | 102 | pass -103 | +103 | 104 | def self_as_kw_only_argument(this, *, self): | ^^^^ N805 105 | pass @@ -207,7 +206,7 @@ N805.py:104:34: N805 First argument of a method should be named `self` N805.py:107:24: N805 First argument of a method should be named `self` | 105 | pass -106 | +106 | 107 | def self_as_varags(this, *self): | ^^^^ N805 108 | pass @@ -217,7 +216,7 @@ N805.py:107:24: N805 First argument of a method should be named `self` N805.py:110:24: N805 First argument of a method should be named `self` | 108 | pass -109 | +109 | 110 | def self_as_kwargs(this, **self): | ^^^^ N805 111 | pass @@ -251,7 +250,7 @@ N805.py:115:20: N805 [*] First argument of a method should be named `self` N805.py:119:20: N805 [*] First argument of a method should be named `self` | 117 | this -118 | +118 | 119 | def bad_method(this): | ^^^^ N805 120 | self = this diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N806_N806.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N806_N806.py.snap index f66bba153037d..1dbb26dd54d28 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N806_N806.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N806_N806.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N806.py:12:5: N806 Variable `Camel` in function should be lowercase | @@ -33,7 +32,7 @@ N806.py:46:5: N806 Variable `Bad` in function should be lowercase N806.py:53:5: N806 Variable `Bad` in function should be lowercase | 51 | from django.utils.module_loading import import_string -52 | +52 | 53 | Bad = import_string("django.core.exceptions.ValidationError") # N806 | ^^^ N806 54 | ValidationError = import_string("django.core.exceptions.ValidationError") # OK @@ -42,7 +41,7 @@ N806.py:53:5: N806 Variable `Bad` in function should be lowercase N806.py:56:5: N806 Variable `Bad` in function should be lowercase | 54 | ValidationError = import_string("django.core.exceptions.ValidationError") # OK -55 | +55 | 56 | Bad = apps.get_model() # N806 | ^^^ N806 57 | Bad = apps.get_model(model_name="Stream") # N806 @@ -53,7 +52,7 @@ N806.py:57:5: N806 Variable `Bad` in function should be lowercase 56 | Bad = apps.get_model() # N806 57 | Bad = apps.get_model(model_name="Stream") # N806 | ^^^ N806 -58 | +58 | 59 | Address: Type = apps.get_model("zerver", variable) # OK | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N811_N811.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N811_N811.py.snap index 680195dbffe53..c874ee2ad88e6 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N811_N811.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N811_N811.py.snap @@ -43,6 +43,6 @@ N811.py:5:17: N811 Constant `C` imported as non-constant `c` 4 | import mod.CON as c 5 | from mod import C as c | ^^^^^^ N811 -6 | +6 | 7 | # These are all OK: | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N814_N814.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N814_N814.py.snap index 57da8ddfaeed8..ab73bb36f1836 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N814_N814.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N814_N814.py.snap @@ -23,6 +23,6 @@ N814.py:3:17: N814 Camelcase `AnotherCamelCase` imported as constant `ANOTHER_CA 2 | from mod import CamelCase as CAMELCASE 3 | from mod import AnotherCamelCase as ANOTHER_CAMELCASE | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ N814 -4 | +4 | 5 | # These are all OK: | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__camelcase_imported_as_incorrect_convention.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__camelcase_imported_as_incorrect_convention.snap index 78972b3152b7c..dfcf9d31f56f3 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__camelcase_imported_as_incorrect_convention.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__camelcase_imported_as_incorrect_convention.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N817.py:1:8: N817 CamelCase `CaMel` imported as acronym `CM` | @@ -30,7 +29,7 @@ N817.py:7:23: N817 CamelCase `ElementTree` imported as acronym `ET` 6 | import xml.etree.ElementTree as ET 7 | from xml.etree import ElementTree as ET | ^^^^^^^^^^^^^^^^^ N817 -8 | +8 | 9 | # Always an error (relative import) | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__classmethod_decorators.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__classmethod_decorators.snap index ec15dcc3c0fe5..6d28da75c6806 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__classmethod_decorators.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__classmethod_decorators.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N805.py:7:20: N805 [*] First argument of a method should be named `self` | @@ -43,7 +42,7 @@ N805.py:11:30: N805 [*] First argument of a method should be named `self` N805.py:63:29: N805 [*] First argument of a method should be named `self` | 61 | pass -62 | +62 | 63 | def bad_method_pos_only(this, blah, /, something: str): | ^^^^ N805 64 | pass @@ -130,7 +129,7 @@ N805.py:98:26: N805 First argument of a method should be named `self` N805.py:101:35: N805 First argument of a method should be named `self` | 99 | pass -100 | +100 | 101 | def self_as_pos_only_argument(this, self, /): | ^^^^ N805 102 | pass @@ -140,7 +139,7 @@ N805.py:101:35: N805 First argument of a method should be named `self` N805.py:104:34: N805 First argument of a method should be named `self` | 102 | pass -103 | +103 | 104 | def self_as_kw_only_argument(this, *, self): | ^^^^ N805 105 | pass @@ -150,7 +149,7 @@ N805.py:104:34: N805 First argument of a method should be named `self` N805.py:107:24: N805 First argument of a method should be named `self` | 105 | pass -106 | +106 | 107 | def self_as_varags(this, *self): | ^^^^ N805 108 | pass @@ -160,7 +159,7 @@ N805.py:107:24: N805 First argument of a method should be named `self` N805.py:110:24: N805 First argument of a method should be named `self` | 108 | pass -109 | +109 | 110 | def self_as_kwargs(this, **self): | ^^^^ N805 111 | pass @@ -194,7 +193,7 @@ N805.py:115:20: N805 [*] First argument of a method should be named `self` N805.py:119:20: N805 [*] First argument of a method should be named `self` | 117 | this -118 | +118 | 119 | def bad_method(this): | ^^^^ N805 120 | self = this diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N801_N801.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N801_N801.py.snap index 64d70b7ecf46a..24d123032c205 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N801_N801.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N801_N801.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N801.py:4:7: N801 Class name `stillBad` should use CapWords convention | 2 | pass -3 | +3 | 4 | class stillBad: | ^^^^^^^^ N801 5 | pass @@ -14,7 +13,7 @@ N801.py:4:7: N801 Class name `stillBad` should use CapWords convention N801.py:10:7: N801 Class name `STILL_BAD` should use CapWords convention | 8 | pass - 9 | + 9 | 10 | class STILL_BAD: | ^^^^^^^^^ N801 11 | pass diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N802_N802.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N802_N802.py.snap index 48d63f69d9b45..223636244b652 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N802_N802.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N802_N802.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N802.py:6:5: N802 Function name `stillBad` should be lowercase | 4 | pass -5 | +5 | 6 | def stillBad(): | ^^^^^^^^ N802 7 | pass @@ -14,7 +13,7 @@ N802.py:6:5: N802 Function name `stillBad` should be lowercase N802.py:13:9: N802 Function name `stillBad` should be lowercase | 11 | return super().tearDown() -12 | +12 | 13 | def stillBad(self): | ^^^^^^^^ N802 14 | return super().tearDown() diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N803_N803.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N803_N803.py.snap index 7a89eea0d269a..6eac6d5d8d4f8 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N803_N803.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N803_N803.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N803.py:4:16: N803 Argument name `stillBad` should be lowercase | 2 | return _, a, badAllowed -3 | +3 | 4 | def func(_, a, stillBad): | ^^^^^^^^ N803 5 | return _, a, stillBad @@ -14,7 +13,7 @@ N803.py:4:16: N803 Argument name `stillBad` should be lowercase N803.py:11:28: N803 Argument name `stillBad` should be lowercase | 9 | return _, a, badAllowed -10 | +10 | 11 | def method(self, _, a, stillBad): | ^^^^^^^^ N803 12 | return _, a, stillBad diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N804_N804.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N804_N804.py.snap index c8848ff50e60b..8afa86cd06c81 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N804_N804.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N804_N804.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N804.py:5:27: N804 [*] First argument of a class method should be named `cls` | @@ -81,7 +80,7 @@ N804.py:18:20: N804 [*] First argument of a class method should be named `cls` N804.py:21:18: N804 [*] First argument of a class method should be named `cls` | 19 | pass -20 | +20 | 21 | def stillBad(self): | ^^^^ N804 22 | pass diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N805_N805.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N805_N805.py.snap index 743bef9166a4a..f6ed863145a25 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N805_N805.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N805_N805.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N805.py:7:20: N805 [*] First argument of a method should be named `self` | @@ -24,7 +23,7 @@ N805.py:7:20: N805 [*] First argument of a method should be named `self` N805.py:10:18: N805 [*] First argument of a method should be named `self` | 8 | pass - 9 | + 9 | 10 | def stillBad(this): | ^^^^ N805 11 | pass @@ -44,7 +43,7 @@ N805.py:10:18: N805 [*] First argument of a method should be named `self` N805.py:15:24: N805 [*] First argument of a method should be named `self` | 13 | if False: -14 | +14 | 15 | def badAllowed(this): | ^^^^ N805 16 | pass @@ -64,7 +63,7 @@ N805.py:15:24: N805 [*] First argument of a method should be named `self` N805.py:18:22: N805 [*] First argument of a method should be named `self` | 16 | pass -17 | +17 | 18 | def stillBad(this): | ^^^^ N805 19 | pass @@ -169,7 +168,7 @@ N805.py:55:20: N805 First argument of a method should be named `self` N805.py:58:18: N805 First argument of a method should be named `self` | 56 | pass -57 | +57 | 58 | def stillBad(this, blah, /, self, something: str): | ^^^^ N805 59 | pass diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N806_N806.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N806_N806.py.snap index 54f0782f26e82..d5a3d42215215 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N806_N806.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N806_N806.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N806.py:3:5: N806 Variable `stillBad` in function should be lowercase | @@ -8,7 +7,7 @@ N806.py:3:5: N806 Variable `stillBad` in function should be lowercase 2 | badAllowed = 0 3 | stillBad = 0 | ^^^^^^^^ N806 -4 | +4 | 5 | BAD_ALLOWED = 0 | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N807_N807.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N807_N807.py.snap index 9efd1ac9ea687..c5de6c4f1f33f 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N807_N807.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N807_N807.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N807.py:4:5: N807 Function name should not start and end with `__` | 2 | pass -3 | +3 | 4 | def __stillBad__(): | ^^^^^^^^^^^^ N807 5 | pass @@ -14,7 +13,7 @@ N807.py:4:5: N807 Function name should not start and end with `__` N807.py:12:9: N807 Function name should not start and end with `__` | 10 | pass -11 | +11 | 12 | def __stillBad__(): | ^^^^^^^^^^^^ N807 13 | pass diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N811_N811.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N811_N811.py.snap index 48c3b03770445..bcd0ed596cdce 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N811_N811.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N811_N811.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N811.py:2:8: N811 Constant `STILL_BAD` imported as non-constant `stillBad` | 1 | import mod.BAD_ALLOWED as badAllowed 2 | import mod.STILL_BAD as stillBad | ^^^^^^^^^^^^^^^^^^^^^^^^^ N811 -3 | +3 | 4 | from mod import BAD_ALLOWED as badAllowed | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N812_N812.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N812_N812.py.snap index 59b53b5a9846f..d198c0546e9f1 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N812_N812.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N812_N812.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N812.py:2:8: N812 Lowercase `stillbad` imported as non-lowercase `stillBad` | 1 | import mod.badallowed as badAllowed 2 | import mod.stillbad as stillBad | ^^^^^^^^^^^^^^^^^^^^^^^^ N812 -3 | +3 | 4 | from mod import badallowed as BadAllowed | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N813_N813.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N813_N813.py.snap index bff4a4bbd11e0..021d450283983 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N813_N813.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N813_N813.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N813.py:2:8: N813 Camelcase `stillBad` imported as lowercase `stillbad` | 1 | import mod.BadAllowed as badallowed 2 | import mod.stillBad as stillbad | ^^^^^^^^^^^^^^^^^^^^^^^^ N813 -3 | +3 | 4 | from mod import BadAllowed as badallowed | @@ -16,7 +15,7 @@ N813.py:5:17: N813 Camelcase `StillBad` imported as lowercase `stillbad` 4 | from mod import BadAllowed as badallowed 5 | from mod import StillBad as stillbad | ^^^^^^^^^^^^^^^^^^^^ N813 -6 | +6 | 7 | from mod import BadAllowed as bad_allowed | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N814_N814.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N814_N814.py.snap index e395e7f13d235..d5b4ef9e74828 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N814_N814.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N814_N814.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N814.py:2:8: N814 Camelcase `StillBad` imported as constant `STILLBAD` | 1 | import mod.BadAllowed as BADALLOWED 2 | import mod.StillBad as STILLBAD | ^^^^^^^^^^^^^^^^^^^^^^^^ N814 -3 | +3 | 4 | from mod import BadAllowed as BADALLOWED | @@ -16,7 +15,7 @@ N814.py:5:17: N814 Camelcase `StillBad` imported as constant `STILLBAD` 4 | from mod import BadAllowed as BADALLOWED 5 | from mod import StillBad as STILLBAD | ^^^^^^^^^^^^^^^^^^^^ N814 -6 | +6 | 7 | from mod import BadAllowed as BAD_ALLOWED | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N815_N815.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N815_N815.py.snap index 63a2ed9b4eb2c..6712a94c4e273 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N815_N815.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N815_N815.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N815.py:3:5: N815 Variable `stillBad` in class scope should not be mixedCase | @@ -8,7 +7,7 @@ N815.py:3:5: N815 Variable `stillBad` in class scope should not be mixedCase 2 | badAllowed = 0 3 | stillBad = 0 | ^^^^^^^^ N815 -4 | +4 | 5 | _badAllowed = 0 | @@ -17,7 +16,7 @@ N815.py:6:5: N815 Variable `_stillBad` in class scope should not be mixedCase 5 | _badAllowed = 0 6 | _stillBad = 0 | ^^^^^^^^^ N815 -7 | +7 | 8 | bad_Allowed = 0 | @@ -26,7 +25,7 @@ N815.py:9:5: N815 Variable `still_Bad` in class scope should not be mixedCase 8 | bad_Allowed = 0 9 | still_Bad = 0 | ^^^^^^^^^ N815 -10 | +10 | 11 | class D(TypedDict): | @@ -36,7 +35,7 @@ N815.py:13:5: N815 Variable `stillBad` in class scope should not be mixedCase 12 | badAllowed: bool 13 | stillBad: bool | ^^^^^^^^ N815 -14 | +14 | 15 | _badAllowed: list | @@ -45,7 +44,7 @@ N815.py:16:5: N815 Variable `_stillBad` in class scope should not be mixedCase 15 | _badAllowed: list 16 | _stillBad: list | ^^^^^^^^^ N815 -17 | +17 | 18 | bad_Allowed: set | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N816_N816.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N816_N816.py.snap index a29d38808992e..779cd8fd65c42 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N816_N816.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N816_N816.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N816.py:2:1: N816 Variable `stillBad` in global scope should not be mixedCase | 1 | badAllowed = 0 2 | stillBad = 0 | ^^^^^^^^ N816 -3 | +3 | 4 | _badAllowed = 0 | @@ -16,7 +15,7 @@ N816.py:5:1: N816 Variable `_stillBad` in global scope should not be mixedCase 4 | _badAllowed = 0 5 | _stillBad = 0 | ^^^^^^^^^ N816 -6 | +6 | 7 | bad_Allowed = 0 | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N817_N817.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N817_N817.py.snap index 4ab2508d9fa65..605e62924b170 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N817_N817.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N817_N817.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N817.py:2:8: N817 CamelCase `StillBad` imported as acronym `SB` | 1 | import mod.BadAllowed as BA 2 | import mod.StillBad as SB | ^^^^^^^^^^^^^^^^^^ N817 -3 | +3 | 4 | from mod import BadAllowed as BA | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N818_N818.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N818_N818.py.snap index e33f176810709..3a27ac47f09c5 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N818_N818.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N818_N818.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N818.py:4:7: N818 Exception name `StillBad` should be named with an Error suffix | 2 | pass -3 | +3 | 4 | class StillBad(Exception): | ^^^^^^^^ N818 5 | pass @@ -14,7 +13,7 @@ N818.py:4:7: N818 Exception name `StillBad` should be named with an Error suffix N818.py:10:7: N818 Exception name `StillBad` should be named with an Error suffix | 8 | pass - 9 | + 9 | 10 | class StillBad(AnotherError): | ^^^^^^^^ N818 11 | pass diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__staticmethod_decorators.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__staticmethod_decorators.snap index 2f54a26b90883..c1a6d0298a115 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__staticmethod_decorators.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__staticmethod_decorators.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- N805.py:7:20: N805 [*] First argument of a method should be named `self` | @@ -81,7 +80,7 @@ N805.py:34:15: N805 [*] First argument of a method should be named `self` N805.py:63:29: N805 [*] First argument of a method should be named `self` | 61 | pass -62 | +62 | 63 | def bad_method_pos_only(this, blah, /, something: str): | ^^^^ N805 64 | pass @@ -168,7 +167,7 @@ N805.py:98:26: N805 First argument of a method should be named `self` N805.py:101:35: N805 First argument of a method should be named `self` | 99 | pass -100 | +100 | 101 | def self_as_pos_only_argument(this, self, /): | ^^^^ N805 102 | pass @@ -178,7 +177,7 @@ N805.py:101:35: N805 First argument of a method should be named `self` N805.py:104:34: N805 First argument of a method should be named `self` | 102 | pass -103 | +103 | 104 | def self_as_kw_only_argument(this, *, self): | ^^^^ N805 105 | pass @@ -188,7 +187,7 @@ N805.py:104:34: N805 First argument of a method should be named `self` N805.py:107:24: N805 First argument of a method should be named `self` | 105 | pass -106 | +106 | 107 | def self_as_varags(this, *self): | ^^^^ N805 108 | pass @@ -198,7 +197,7 @@ N805.py:107:24: N805 First argument of a method should be named `self` N805.py:110:24: N805 First argument of a method should be named `self` | 108 | pass -109 | +109 | 110 | def self_as_kwargs(this, **self): | ^^^^ N805 111 | pass @@ -232,7 +231,7 @@ N805.py:115:20: N805 [*] First argument of a method should be named `self` N805.py:119:20: N805 [*] First argument of a method should be named `self` | 117 | this -118 | +118 | 119 | def bad_method(this): | ^^^^ N805 120 | self = this diff --git a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF101_PERF101.py.snap b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF101_PERF101.py.snap index 35bf8c149cf0c..fd545e136452c 100644 --- a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF101_PERF101.py.snap +++ b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF101_PERF101.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/perflint/mod.rs -snapshot_kind: text --- PERF101.py:7:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it | 5 | foo_int = 123 -6 | +6 | 7 | for i in list(foo_tuple): # PERF101 | ^^^^^^^^^^^^^^^ PERF101 8 | pass @@ -25,7 +24,7 @@ PERF101.py:7:10: PERF101 [*] Do not cast an iterable to `list` before iterating PERF101.py:10:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it | 8 | pass - 9 | + 9 | 10 | for i in list(foo_list): # PERF101 | ^^^^^^^^^^^^^^ PERF101 11 | pass @@ -45,7 +44,7 @@ PERF101.py:10:10: PERF101 [*] Do not cast an iterable to `list` before iterating PERF101.py:13:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it | 11 | pass -12 | +12 | 13 | for i in list(foo_set): # PERF101 | ^^^^^^^^^^^^^ PERF101 14 | pass @@ -65,7 +64,7 @@ PERF101.py:13:10: PERF101 [*] Do not cast an iterable to `list` before iterating PERF101.py:16:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it | 14 | pass -15 | +15 | 16 | for i in list((1, 2, 3)): # PERF101 | ^^^^^^^^^^^^^^^ PERF101 17 | pass @@ -85,7 +84,7 @@ PERF101.py:16:10: PERF101 [*] Do not cast an iterable to `list` before iterating PERF101.py:19:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it | 17 | pass -18 | +18 | 19 | for i in list([1, 2, 3]): # PERF101 | ^^^^^^^^^^^^^^^ PERF101 20 | pass @@ -105,7 +104,7 @@ PERF101.py:19:10: PERF101 [*] Do not cast an iterable to `list` before iterating PERF101.py:22:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it | 20 | pass -21 | +21 | 22 | for i in list({1, 2, 3}): # PERF101 | ^^^^^^^^^^^^^^^ PERF101 23 | pass @@ -125,7 +124,7 @@ PERF101.py:22:10: PERF101 [*] Do not cast an iterable to `list` before iterating PERF101.py:25:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it | 23 | pass -24 | +24 | 25 | for i in list( | __________^ 26 | | { @@ -159,7 +158,7 @@ PERF101.py:25:10: PERF101 [*] Do not cast an iterable to `list` before iterating PERF101.py:34:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it | 32 | pass -33 | +33 | 34 | for i in list( # Comment | __________^ 35 | | {1, 2, 3} @@ -184,7 +183,7 @@ PERF101.py:34:10: PERF101 [*] Do not cast an iterable to `list` before iterating PERF101.py:57:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it | 55 | foo_list.append(i + 1) -56 | +56 | 57 | for i in list(foo_list): # PERF101 | ^^^^^^^^^^^^^^ PERF101 58 | # Make sure we match the correct list @@ -205,7 +204,7 @@ PERF101.py:57:10: PERF101 [*] Do not cast an iterable to `list` before iterating PERF101.py:69:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it | 67 | x, y, nested_tuple = (1, 2, (3, 4, 5)) -68 | +68 | 69 | for i in list(nested_tuple): # PERF101 | ^^^^^^^^^^^^^^^^^^ PERF101 70 | pass @@ -225,7 +224,7 @@ PERF101.py:69:10: PERF101 [*] Do not cast an iterable to `list` before iterating PERF101.py:86:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it | 84 | import builtins -85 | +85 | 86 | for i in builtins.list(nested_tuple): # PERF101 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PERF101 87 | pass diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E101_E101.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E101_E101.py.snap index 0a6be93231402..08e2e86ba5693 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E101_E101.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E101_E101.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E101.py:11:1: E101 Indentation contains mixed spaces and tabs | @@ -8,7 +7,7 @@ E101.py:11:1: E101 Indentation contains mixed spaces and tabs 10 | # E101 11 | print("mixed starts with tab") | ^^^^^^ E101 -12 | +12 | 13 | def func_mixed_start_with_space(): | @@ -18,7 +17,7 @@ E101.py:15:1: E101 Indentation contains mixed spaces and tabs 14 | # E101 15 | print("mixed starts with space") | ^^^^^^^^^^^^^^^ E101 -16 | +16 | 17 | def xyz(): | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E201_E20.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E201_E20.py.snap index bc57c17a9d331..0aea3ff5f73ce 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E201_E20.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E201_E20.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E20.py:2:6: E201 [*] Whitespace after '(' | @@ -130,7 +129,7 @@ E20.py:107:6: E201 [*] Whitespace after '[' 106 | #: E201:1:6 107 | spam[ ~ham] | ^ E201 -108 | +108 | 109 | #: Okay | = help: Remove whitespace before '[' @@ -170,7 +169,7 @@ E20.py:145:5: E201 [*] Whitespace after '[' 144 | #: E201:1:5 145 | ham[ : upper] | ^ E201 -146 | +146 | 147 | #: Okay | = help: Remove whitespace before '[' diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E202_E20.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E202_E20.py.snap index d8db76fdef2d9..23b47a9a9244a 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E202_E20.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E202_E20.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E20.py:19:23: E202 [*] Whitespace before ')' | @@ -152,7 +151,7 @@ E20.py:172:12: E202 [*] Whitespace before ']' 171 | #: E202:1:12 172 | ham[upper : ] | ^ E202 -173 | +173 | 174 | #: E203:1:10 | = help: Remove whitespace before ']' diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E203_E20.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E203_E20.py.snap index 82c409afbf264..bcac95a6e6ead 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E203_E20.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E203_E20.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E20.py:51:10: E203 [*] Whitespace before ':' | @@ -192,7 +191,7 @@ E20.py:126:16: E203 [*] Whitespace before ':' 125 | #: E203:1:19 126 | {lower + offset : upper + offset} | ^ E203 -127 | +127 | 128 | #: E203:1:19 | = help: Remove whitespace before ':' @@ -212,7 +211,7 @@ E20.py:129:19: E203 [*] Whitespace before ':' 128 | #: E203:1:19 129 | ham[lower + offset : upper + offset] | ^^ E203 -130 | +130 | 131 | #: Okay | = help: Remove whitespace before ':' @@ -232,7 +231,7 @@ E20.py:157:21: E203 [*] Whitespace before ':' 156 | #: E203:1:21 157 | ham[lower + offset : : upper + offset] | ^ E203 -158 | +158 | 159 | #: E203:1:20 | = help: Remove whitespace before ':' @@ -252,7 +251,7 @@ E20.py:160:20: E203 [*] Whitespace before ':' 159 | #: E203:1:20 160 | ham[lower + offset: :upper + offset] | ^ E203 -161 | +161 | 162 | #: E203:1:20 | = help: Remove whitespace before ':' @@ -272,7 +271,7 @@ E20.py:163:20: E203 [*] Whitespace before ':' 162 | #: E203:1:20 163 | ham[{lower + offset : upper + offset} : upper + offset] | ^ E203 -164 | +164 | 165 | #: Okay | = help: Remove whitespace before ':' @@ -292,7 +291,7 @@ E20.py:175:10: E203 [*] Whitespace before ':' 174 | #: E203:1:10 175 | ham[upper :] | ^^ E203 -176 | +176 | 177 | #: Okay | = help: Remove whitespace before ':' @@ -312,7 +311,7 @@ E20.py:181:14: E203 [*] Whitespace before ':' 180 | #: E203:1:13 181 | ham[lower + 1 :, "columnname"] | ^^ E203 -182 | +182 | 183 | #: Okay | = help: Remove whitespace before ':' @@ -332,7 +331,7 @@ E20.py:187:17: E203 [*] Whitespace before ':' 186 | #: E203:1:13 187 | f"{ham[lower + 1 :, "columnname"]}" | ^^ E203 -188 | +188 | 189 | #: Okay: https://github.com/astral-sh/ruff/issues/12023 | = help: Remove whitespace before ':' diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E221_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E221_E22.py.snap index 5a5cd4fad1e73..ed500ca29f87b 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E221_E22.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E221_E22.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E22.py:3:6: E221 [*] Multiple spaces before operator | @@ -172,7 +171,7 @@ E22.py:19:14: E221 [*] Multiple spaces before operator E22.py:184:5: E221 [*] Multiple spaces before operator | 182 | #: -183 | +183 | 184 | if a == 1: | ^^ E221 185 | print(a) diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E222_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E222_E22.py.snap index 9fd516cd3ee7c..9b6879bfbec07 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E222_E22.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E222_E22.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E22.py:28:8: E222 [*] Multiple spaces after operator | @@ -109,7 +108,7 @@ E22.py:36:7: E222 [*] Multiple spaces after operator E22.py:184:9: E222 [*] Multiple spaces after operator | 182 | #: -183 | +183 | 184 | if a == 1: | ^^ E222 185 | print(a) diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E252_E25.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E252_E25.py.snap index 102fb70ec6aba..5765ad2908399 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E252_E25.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E252_E25.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E25.py:46:15: E252 [*] Missing whitespace around parameter equals | @@ -279,7 +278,7 @@ E25.py:64:96: E252 [*] Missing whitespace around parameter equals E25.py:67:18: E252 [*] Missing whitespace around parameter equals | 65 | pass -66 | +66 | 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: | ^ E252 68 | pass @@ -299,7 +298,7 @@ E25.py:67:18: E252 [*] Missing whitespace around parameter equals E25.py:67:18: E252 [*] Missing whitespace around parameter equals | 65 | pass -66 | +66 | 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: | ^ E252 68 | pass @@ -319,7 +318,7 @@ E25.py:67:18: E252 [*] Missing whitespace around parameter equals E25.py:67:26: E252 [*] Missing whitespace around parameter equals | 65 | pass -66 | +66 | 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: | ^ E252 68 | pass @@ -339,7 +338,7 @@ E25.py:67:26: E252 [*] Missing whitespace around parameter equals E25.py:67:33: E252 [*] Missing whitespace around parameter equals | 65 | pass -66 | +66 | 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: | ^ E252 68 | pass @@ -359,7 +358,7 @@ E25.py:67:33: E252 [*] Missing whitespace around parameter equals E25.py:67:49: E252 [*] Missing whitespace around parameter equals | 65 | pass -66 | +66 | 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: | ^ E252 68 | pass @@ -379,7 +378,7 @@ E25.py:67:49: E252 [*] Missing whitespace around parameter equals E25.py:67:49: E252 [*] Missing whitespace around parameter equals | 65 | pass -66 | +66 | 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: | ^ E252 68 | pass @@ -399,7 +398,7 @@ E25.py:67:49: E252 [*] Missing whitespace around parameter equals E25.py:67:64: E252 [*] Missing whitespace around parameter equals | 65 | pass -66 | +66 | 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: | ^ E252 68 | pass @@ -419,7 +418,7 @@ E25.py:67:64: E252 [*] Missing whitespace around parameter equals E25.py:67:64: E252 [*] Missing whitespace around parameter equals | 65 | pass -66 | +66 | 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: | ^ E252 68 | pass @@ -439,7 +438,7 @@ E25.py:67:64: E252 [*] Missing whitespace around parameter equals E25.py:67:80: E252 [*] Missing whitespace around parameter equals | 65 | pass -66 | +66 | 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: | ^ E252 68 | pass @@ -459,7 +458,7 @@ E25.py:67:80: E252 [*] Missing whitespace around parameter equals E25.py:67:96: E252 [*] Missing whitespace around parameter equals | 65 | pass -66 | +66 | 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: | ^ E252 68 | pass diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E262_E26.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E262_E26.py.snap index 413d87a7fdc98..a20957b68dd70 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E262_E26.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E262_E26.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E26.py:4:12: E262 [*] Inline comment should start with `# ` | @@ -92,7 +91,7 @@ E26.py:66:9: E262 [*] Inline comment should start with `# ` 65 | # (Two spaces) Ok for block comment 66 | a = 42 # (Two spaces) | ^^^^^^^^^^^^^^^ E262 -67 | +67 | 68 | #: E265:5:1 | = help: Format space @@ -110,10 +109,10 @@ E26.py:66:9: E262 [*] Inline comment should start with `# ` E26.py:84:8: E262 [*] Inline comment should start with `# ` | 82 | ## Foo -83 | +83 | 84 | a = 1 ## Foo | ^^^^^^ E262 -85 | +85 | 86 | a = 1 #:Foo | = help: Format space @@ -130,7 +129,7 @@ E26.py:84:8: E262 [*] Inline comment should start with `# ` E26.py:86:8: E262 [*] Inline comment should start with `# ` | 84 | a = 1 ## Foo -85 | +85 | 86 | a = 1 #:Foo | ^^^^^ E262 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E265_E26.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E265_E26.py.snap index 0e04de2d18d88..d20b25b5c0cda 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E265_E26.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E265_E26.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E26.py:10:1: E265 [*] Block comment should start with `# ` | @@ -70,7 +69,7 @@ E26.py:32:1: E265 [*] Block comment should start with `# ` 31 | #: Okay 32 | #!/usr/bin/env python | ^^^^^^^^^^^^^^^^^^^^^ E265 -33 | +33 | 34 | pass # an inline comment | = help: Format space @@ -108,10 +107,10 @@ E26.py:73:1: E265 [*] Block comment should start with `# ` E26.py:78:1: E265 [*] Block comment should start with `# ` | 76 | #: Colon prefix is okay -77 | +77 | 78 | ###This is a variable ### | ^^^^^^^^^^^^^^^^^^^^^^^^^ E265 -79 | +79 | 80 | # We should strip the space, but preserve the hashes. | = help: Format space diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E266_E26.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E266_E26.py.snap index d71c78139bac5..b32057f33758f 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E266_E26.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E266_E26.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E26.py:19:5: E266 [*] Too many leading `#` before block comment | 17 | def how_it_feel(r): -18 | +18 | 19 | ### This is a variable ### | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E266 20 | a = 42 @@ -25,7 +24,7 @@ E26.py:19:5: E266 [*] Too many leading `#` before block comment E26.py:22:5: E266 [*] Too many leading `#` before block comment | 20 | a = 42 -21 | +21 | 22 | ### Of course it is unused | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E266 23 | return @@ -90,7 +89,7 @@ E26.py:82:1: E266 [*] Too many leading `#` before block comment 81 | #: E266:1:3 82 | ## Foo | ^^^^^^^ E266 -83 | +83 | 84 | a = 1 ## Foo | = help: Remove leading `#` diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E271_E27.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E271_E27.py.snap index d834555835457..71f1f1b6f348c 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E271_E27.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E271_E27.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E27.py:4:9: E271 [*] Multiple spaces after keyword | @@ -196,7 +195,7 @@ E27.py:71:5: E271 [*] Multiple spaces after keyword 70 | #: E271 71 | type Number = int | ^^ E271 -72 | +72 | 73 | #: E273 | = help: Replace with single space diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E273_E27.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E273_E27.py.snap index 9b2e8fadf6880..c7ce1e345dd2e 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E273_E27.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E273_E27.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E27.py:11:9: E273 [*] Tab after keyword | @@ -112,7 +111,7 @@ E27.py:74:5: E273 [*] Tab after keyword 73 | #: E273 74 | type Number = int | ^^^^ E273 -75 | +75 | 76 | #: E275 | = help: Replace with single space diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30_syntax_error.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30_syntax_error.py.snap index afe020f83f3e3..5e99bc6e15ecd 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30_syntax_error.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E30_syntax_error.py:4:15: SyntaxError: Expected ']', found '(' | 2 | # parenthesis. -3 | +3 | 4 | def foo[T1, T2(): | ^ 5 | pass @@ -34,11 +33,11 @@ E30_syntax_error.py:15:5: E301 Expected 1 blank line, found 0 E30_syntax_error.py:18:11: SyntaxError: Expected ')', found newline | 16 | pass -17 | +17 | 18 | foo = Foo( | ^ -19 | -20 | +19 | +20 | 21 | def top( | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30.py.snap index a276cd51e89c8..5c422baa3d369 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E30.py:533:1: E302 [*] Expected 2 blank lines, found 0 | @@ -47,7 +46,7 @@ E30.py:540:1: E302 [*] Expected 2 blank lines, found 0 E30.py:549:1: E302 [*] Expected 2 blank lines, found 1 | 547 | pass -548 | +548 | 549 | def b(): | ^^^ E302 550 | pass @@ -67,7 +66,7 @@ E30.py:549:1: E302 [*] Expected 2 blank lines, found 1 E30.py:560:1: E302 [*] Expected 2 blank lines, found 1 | 558 | # comment -559 | +559 | 560 | def b(): | ^^^ E302 561 | pass @@ -87,7 +86,7 @@ E30.py:560:1: E302 [*] Expected 2 blank lines, found 1 E30.py:569:1: E302 [*] Expected 2 blank lines, found 1 | 567 | pass -568 | +568 | 569 | async def b(): | ^^^^^ E302 570 | pass @@ -107,7 +106,7 @@ E30.py:569:1: E302 [*] Expected 2 blank lines, found 1 E30.py:578:1: E302 [*] Expected 2 blank lines, found 1 | 576 | pass -577 | +577 | 578 | async def x(y: int = 1): | ^^^^^ E302 579 | pass @@ -207,7 +206,7 @@ E30.py:624:1: E302 [*] Expected 2 blank lines, found 0 E30.py:634:1: E302 [*] Expected 2 blank lines, found 1 | 632 | def fn(a: str) -> str: ... -633 | +633 | 634 | def fn(a: int | str) -> int | str: | ^^^ E302 635 | ... diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_docstring.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_docstring.py.snap index ef9c64013869f..9e725801e05a2 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_docstring.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_docstring.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E302_first_line_docstring.py:3:1: E302 [*] Expected 2 blank lines, found 1 | 1 | """Test where the error is after the module's docstring.""" -2 | +2 | 3 | def fn(): | ^^^ E302 4 | pass diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_expression.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_expression.py.snap index 2626b10faa8e4..ecbe189c7679f 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_expression.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_expression.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E302_first_line_expression.py:3:1: E302 [*] Expected 2 blank lines, found 1 | 1 | "Test where the first line is a comment, " + "and the rule violation follows it." -2 | +2 | 3 | def fn(): | ^^^ E302 4 | pass diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_function.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_function.py.snap index ac34dfa6a0e09..cd03aac6573af 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_function.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_function.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E302_first_line_function.py:4:1: E302 [*] Expected 2 blank lines, found 1 | 2 | pass -3 | +3 | 4 | def fn2(): | ^^^ E302 5 | pass diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_statement.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_statement.py.snap index 00f4d5d72d144..ac0bdf5e2e893 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_statement.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_statement.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E302_first_line_statement.py:3:1: E302 [*] Expected 2 blank lines, found 1 | 1 | print("Test where the first line is a statement, and the rule violation follows it.") -2 | +2 | 3 | def fn(): | ^^^ E302 4 | pass diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30_syntax_error.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30_syntax_error.py.snap index 5be869e7196c2..88d95e3ee9a21 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30_syntax_error.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E30_syntax_error.py:4:15: SyntaxError: Expected ']', found '(' | 2 | # parenthesis. -3 | +3 | 4 | def foo[T1, T2(): | ^ 5 | pass @@ -14,7 +13,7 @@ E30_syntax_error.py:4:15: SyntaxError: Expected ']', found '(' E30_syntax_error.py:7:1: E302 Expected 2 blank lines, found 1 | 5 | pass -6 | +6 | 7 | def bar(): | ^^^ E302 8 | pass @@ -34,11 +33,11 @@ E30_syntax_error.py:13:18: SyntaxError: Expected ')', found newline E30_syntax_error.py:18:11: SyntaxError: Expected ')', found newline | 16 | pass -17 | +17 | 18 | foo = Foo( | ^ -19 | -20 | +19 | +20 | 21 | def top( | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30.py.snap index 3f5868e45bd02..5e8f5f9e9ce6b 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E30.py:617:2: E303 [*] Too many blank lines (2) | @@ -24,7 +23,7 @@ E30.py:644:5: E303 [*] Too many blank lines (2) | 644 | # arbitrary comment | ^^^^^^^^^^^^^^^^^^^ E303 -645 | +645 | 646 | def inner(): # E306 not expected (pycodestyle detects E306) | = help: Remove extraneous blank line(s) @@ -77,7 +76,7 @@ E30.py:676:1: E303 [*] Too many blank lines (3) | 676 | # comment | ^^^^^^^^^ E303 -677 | +677 | 678 | print() | = help: Remove extraneous blank line(s) @@ -111,7 +110,7 @@ E30.py:690:5: E303 [*] Too many blank lines (2) | 690 | # another comment | ^^^^^^^^^^^^^^^^^ E303 -691 | +691 | 692 | print() | = help: Remove extraneous blank line(s) @@ -199,7 +198,7 @@ E30.py:734:5: E303 [*] Too many blank lines (2) | 734 | # another comment | ^^^^^^^^^^^^^^^^^ E303 -735 | +735 | 736 | def test(self): pass | = help: Remove extraneous blank line(s) diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30_syntax_error.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30_syntax_error.py.snap index 2744d695abc83..f268b987e1358 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30_syntax_error.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E30_syntax_error.py:4:15: SyntaxError: Expected ']', found '(' | 2 | # parenthesis. -3 | +3 | 4 | def foo[T1, T2(): | ^ 5 | pass @@ -33,11 +32,11 @@ E30_syntax_error.py:13:18: SyntaxError: Expected ')', found newline E30_syntax_error.py:18:11: SyntaxError: Expected ')', found newline | 16 | pass -17 | +17 | 18 | foo = Foo( | ^ -19 | -20 | +19 | +20 | 21 | def top( | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E304_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E304_E30.py.snap index dd9f6cb151880..fe68174f76bd2 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E304_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E304_E30.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E30.py:765:1: E304 [*] Blank lines found after function decorator (1) | 763 | @decorator -764 | +764 | 765 | def function(): | ^^^ E304 766 | pass diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30.py.snap index c5167d251df07..482f2d428e03c 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E30.py:798:1: E305 [*] Expected 2 blank lines after class or function definition, found (1) | @@ -41,7 +40,7 @@ E30.py:809:1: E305 [*] Expected 2 blank lines after class or function definition E30.py:821:1: E305 [*] Expected 2 blank lines after class or function definition, found (1) | 819 | # another comment -820 | +820 | 821 | try: | ^^^ E305 822 | fn() @@ -80,7 +79,7 @@ E30.py:833:1: E305 [*] Expected 2 blank lines after class or function definition E30.py:846:1: E305 [*] Expected 2 blank lines after class or function definition, found (1) | 844 | blah, blah -845 | +845 | 846 | if __name__ == '__main__': | ^^ E305 847 | main() diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30_syntax_error.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30_syntax_error.py.snap index cee866c200270..6d5796ccab8d3 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30_syntax_error.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E30_syntax_error.py:4:15: SyntaxError: Expected ']', found '(' | 2 | # parenthesis. -3 | +3 | 4 | def foo[T1, T2(): | ^ 5 | pass @@ -24,7 +23,7 @@ E30_syntax_error.py:13:18: SyntaxError: Expected ')', found newline E30_syntax_error.py:18:1: E305 Expected 2 blank lines after class or function definition, found (1) | 16 | pass -17 | +17 | 18 | foo = Foo( | ^^^ E305 | @@ -33,11 +32,11 @@ E30_syntax_error.py:18:1: E305 Expected 2 blank lines after class or function de E30_syntax_error.py:18:11: SyntaxError: Expected ')', found newline | 16 | pass -17 | +17 | 18 | foo = Foo( | ^ -19 | -20 | +19 | +20 | 21 | def top( | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30_syntax_error.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30_syntax_error.py.snap index 81b10e944c017..226c3ad35a3f6 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30_syntax_error.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E30_syntax_error.py:4:15: SyntaxError: Expected ']', found '(' | 2 | # parenthesis. -3 | +3 | 4 | def foo[T1, T2(): | ^ 5 | pass @@ -24,11 +23,11 @@ E30_syntax_error.py:13:18: SyntaxError: Expected ')', found newline E30_syntax_error.py:18:11: SyntaxError: Expected ')', found newline | 16 | pass -17 | +17 | 18 | foo = Foo( | ^ -19 | -20 | +19 | +20 | 21 | def top( | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E401_E40.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E401_E40.py.snap index d1b610481a093..86b9b31306792 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E401_E40.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E401_E40.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E40.py:2:1: E401 [*] Multiple imports on one line | 1 | #: E401 2 | import os, sys | ^^^^^^^^^^^^^^ E401 -3 | +3 | 4 | #: Okay | = help: Split imports @@ -47,7 +46,7 @@ E40.py:66:1: E401 [*] Multiple imports on one line 65 | import re as regex, string # also with a comment! 66 | import re as regex, string; x = 1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E401 -67 | +67 | 68 | x = 1; import re as regex, string | = help: Split imports @@ -65,7 +64,7 @@ E40.py:66:1: E401 [*] Multiple imports on one line E40.py:68:8: E401 [*] Multiple imports on one line | 66 | import re as regex, string; x = 1 -67 | +67 | 68 | x = 1; import re as regex, string | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E401 | @@ -86,7 +85,7 @@ E40.py:72:5: E401 [*] Multiple imports on one line 71 | def blah(): 72 | import datetime as dt, copy | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E401 -73 | +73 | 74 | def nested_and_tested(): | = help: Split imports @@ -107,7 +106,7 @@ E40.py:75:9: E401 [*] Multiple imports on one line 74 | def nested_and_tested(): 75 | import builtins, textwrap as tw | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E401 -76 | +76 | 77 | x = 1; import re as regex, string | = help: Split imports @@ -126,7 +125,7 @@ E40.py:75:9: E401 [*] Multiple imports on one line E40.py:77:16: E401 [*] Multiple imports on one line | 75 | import builtins, textwrap as tw -76 | +76 | 77 | x = 1; import re as regex, string | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E401 78 | import re as regex, string; x = 1 @@ -148,7 +147,7 @@ E40.py:78:9: E401 [*] Multiple imports on one line 77 | x = 1; import re as regex, string 78 | import re as regex, string; x = 1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E401 -79 | +79 | 80 | if True: import re as regex, string | = help: Split imports @@ -165,7 +164,7 @@ E40.py:78:9: E401 [*] Multiple imports on one line E40.py:80:14: E401 [*] Multiple imports on one line | 78 | import re as regex, string; x = 1 -79 | +79 | 80 | if True: import re as regex, string | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E401 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E40.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E40.py.snap index 44bf5bc21a18f..bbf2e510a7bb6 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E40.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E40.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E40.py:56:1: E402 Module level import not at top of file | 54 | VERSION = '1.2.3' -55 | +55 | 56 | import foo | ^^^^^^^^^^ E402 57 | #: E402 @@ -18,17 +17,17 @@ E40.py:58:1: E402 Module level import not at top of file 57 | #: E402 58 | import foo | ^^^^^^^^^^ E402 -59 | +59 | 60 | a = 1 | E40.py:62:1: E402 Module level import not at top of file | 60 | a = 1 -61 | +61 | 62 | import bar | ^^^^^^^^^^ E402 -63 | +63 | 64 | #: E401 | @@ -46,14 +45,14 @@ E40.py:66:1: E402 Module level import not at top of file 65 | import re as regex, string # also with a comment! 66 | import re as regex, string; x = 1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E402 -67 | +67 | 68 | x = 1; import re as regex, string | E40.py:68:8: E402 Module level import not at top of file | 66 | import re as regex, string; x = 1 -67 | +67 | 68 | x = 1; import re as regex, string | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E402 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402.ipynb.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402.ipynb.snap index 57da2d9c8107f..9cbf106ef958f 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402.ipynb.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402.ipynb.snap @@ -1,21 +1,20 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E402.ipynb:9:1: E402 Module level import not at top of cell | 7 | os.path - 8 | + 8 | 9 | import pathlib | ^^^^^^^^^^^^^^ E402 -10 | +10 | 11 | import a | E402.ipynb:22:1: E402 Module level import not at top of cell | 20 | __some__magic = 1 -21 | +21 | 22 | import c | ^^^^^^^^ E402 23 | import ok @@ -25,6 +24,6 @@ E402.ipynb:30:1: E402 Module level import not at top of cell | 30 | import no_ok | ^^^^^^^^^^^^ E402 -31 | +31 | 32 | %%time | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402_0.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402_0.py.snap index be3142cbab0ee..dff5430ecbf41 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402_0.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402_0.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E402_0.py:35:1: E402 Module level import not at top of file | 33 | __some__magic = 1 -34 | +34 | 35 | import h | ^^^^^^^^ E402 | @@ -13,7 +12,7 @@ E402_0.py:35:1: E402 Module level import not at top of file E402_0.py:45:1: E402 Module level import not at top of file | 43 | import j -44 | +44 | 45 | import k; import l | ^^^^^^^^ E402 | @@ -21,7 +20,7 @@ E402_0.py:45:1: E402 Module level import not at top of file E402_0.py:45:11: E402 Module level import not at top of file | 43 | import j -44 | +44 | 45 | import k; import l | ^^^^^^^^ E402 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402_1.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402_1.py.snap index 29be45489e11d..a035c4d914b90 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402_1.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402_1.py.snap @@ -1,21 +1,20 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E402_1.py:5:1: E402 Module level import not at top of file | 3 | """Some other docstring.""" -4 | +4 | 5 | import b | ^^^^^^^^ E402 -6 | +6 | 7 | """Some other docstring.""" | E402_1.py:9:1: E402 Module level import not at top of file | 7 | """Some other docstring.""" -8 | +8 | 9 | import c | ^^^^^^^^ E402 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E711_E711.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E711_E711.py.snap index 242bbe9bc30c1..133712eea9ead 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E711_E711.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E711_E711.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E711.py:2:11: E711 [*] Comparison to `None` should be `cond is None` | @@ -169,7 +168,7 @@ E711.py:23:4: E711 [*] Comparison to `None` should be `cond is None` E711.py:26:9: E711 [*] Comparison to `None` should be `cond is None` | 24 | pass -25 | +25 | 26 | if x == None != None: | ^^^^ E711 27 | pass @@ -189,7 +188,7 @@ E711.py:26:9: E711 [*] Comparison to `None` should be `cond is None` E711.py:26:17: E711 [*] Comparison to `None` should be `cond is not None` | 24 | pass -25 | +25 | 26 | if x == None != None: | ^^^^ E711 27 | pass diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E712_E712.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E712_E712.py.snap index 4dc4f086ece07..02f2c26951687 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E712_E712.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E712_E712.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E712.py:2:4: E712 [*] Avoid equality comparisons to `True`; use `if res:` for truth checks | @@ -190,7 +189,7 @@ E712.py:22:4: E712 [*] Avoid equality comparisons to `True`; use `if TrueElement E712.py:25:4: E712 [*] Avoid equality comparisons to `True` or `False` | 23 | pass -24 | +24 | 25 | if res == True != False: | ^^^^^^^^^^^^^^^^^^^^ E712 26 | pass @@ -210,7 +209,7 @@ E712.py:25:4: E712 [*] Avoid equality comparisons to `True` or `False` E712.py:25:4: E712 [*] Avoid equality comparisons to `True` or `False` | 23 | pass -24 | +24 | 25 | if res == True != False: | ^^^^^^^^^^^^^^^^^^^^ E712 26 | pass @@ -230,7 +229,7 @@ E712.py:25:4: E712 [*] Avoid equality comparisons to `True` or `False` E712.py:28:3: E712 [*] Avoid equality comparisons to `True`; use `if TrueElement:` for truth checks | 26 | pass -27 | +27 | 28 | if(True) == TrueElement or x == TrueElement: | ^^^^^^^^^^^^^^^^^^^^^ E712 29 | pass @@ -250,7 +249,7 @@ E712.py:28:3: E712 [*] Avoid equality comparisons to `True`; use `if TrueElement E712.py:31:4: E712 [*] Avoid equality comparisons to `True`; use `if yield i:` for truth checks | 29 | pass -30 | +30 | 31 | if (yield i) == True: | ^^^^^^^^^^^^^^^^^ E712 32 | print("even") diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E721_E721.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E721_E721.py.snap index 076396f50b416..0e257342a926d 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E721_E721.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E721_E721.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E721.py:2:4: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks | @@ -145,14 +144,14 @@ E721.py:140:1: E721 Use `is` and `is not` for type comparisons, or `isinstance() 139 | #: E721 140 | dtype == float | ^^^^^^^^^^^^^^ E721 -141 | +141 | 142 | import builtins | E721.py:144:4: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks | 142 | import builtins -143 | +143 | 144 | if builtins.type(res) == memoryview: # E721 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E721 145 | pass diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E741_E741.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E741_E741.py.snap index 93badbdb676bd..75db1277a61a7 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E741_E741.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E741_E741.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E741.py:3:1: E741 Ambiguous variable name: `l` | 1 | from contextlib import contextmanager -2 | +2 | 3 | l = 0 | ^ E741 4 | I = 0 @@ -36,14 +35,14 @@ E741.py:6:1: E741 Ambiguous variable name: `l` 5 | O = 0 6 | l: int = 0 | ^ E741 -7 | +7 | 8 | a, l = 0, 1 | E741.py:8:4: E741 Ambiguous variable name: `l` | 6 | l: int = 0 - 7 | + 7 | 8 | a, l = 0, 1 | ^ E741 9 | [a, l] = 0, 1 @@ -74,14 +73,14 @@ E741.py:11:5: E741 Ambiguous variable name: `l` 10 | a, *l = 0, 1, 2 11 | a = l = 0 | ^ E741 -12 | +12 | 13 | o = 0 | E741.py:16:5: E741 Ambiguous variable name: `l` | 14 | i = 0 -15 | +15 | 16 | for l in range(3): | ^ E741 17 | pass @@ -115,7 +114,7 @@ E741.py:30:5: E741 Ambiguous variable name: `l` 29 | def f2(): 30 | l = 0 | ^ E741 -31 | +31 | 32 | def f3(): | @@ -133,7 +132,7 @@ E741.py:34:9: E741 Ambiguous variable name: `l` 33 | nonlocal l 34 | l = 1 | ^ E741 -35 | +35 | 36 | f3() | @@ -205,7 +204,7 @@ E741.py:71:22: E741 Ambiguous variable name: `l` E741.py:74:5: E741 Ambiguous variable name: `l` | 72 | pass -73 | +73 | 74 | if (l := 5) > 0: | ^ E741 75 | pass diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W291.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W291.py.snap index a75ff6e87ff14..0f59c043ac25a 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W291.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W291.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- W291.py:1:23: W291 [*] Trailing whitespace | @@ -20,7 +19,7 @@ W291.py:1:23: W291 [*] Trailing whitespace W291.py:4:24: W291 [*] Trailing whitespace | 2 | inside a multiline string''' -3 | +3 | 4 | f'''trailing whitespace | ^ W291 5 | inside a multiline f-string''' diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_0.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_0.py.snap index 4159318729d6a..8da92669c3fc3 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_0.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_0.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- W605_0.py:2:10: W605 [*] Invalid escape sequence: `\.` | 1 | #: W605:1:10 2 | regex = '\.png$' | ^^ W605 -3 | +3 | 4 | #: W605:2:1 | = help: Use a raw string literal @@ -105,7 +104,7 @@ W605_0.py:28:12: W605 [*] Invalid escape sequence: `\.` 27 | #: W605:1:11 28 | return'\.png$' | ^^ W605 -29 | +29 | 30 | #: Okay | = help: Use a raw string literal @@ -123,10 +122,10 @@ W605_0.py:28:12: W605 [*] Invalid escape sequence: `\.` W605_0.py:45:12: W605 [*] Invalid escape sequence: `\_` | 43 | ''' # noqa -44 | +44 | 45 | regex = '\\\_' | ^^ W605 -46 | +46 | 47 | #: W605:1:7 | = help: Add backslash to escape sequence @@ -146,7 +145,7 @@ W605_0.py:48:6: W605 [*] Invalid escape sequence: `\ ` 47 | #: W605:1:7 48 | u'foo\ bar' | ^^ W605 -49 | +49 | 50 | #: W605:1:13 | = help: Use a raw string literal @@ -186,7 +185,7 @@ W605_0.py:57:6: W605 [*] Invalid escape sequence: `\.` 56 | #: W605:1:6 57 | "foo \. bar \t" | ^^ W605 -58 | +58 | 59 | #: W605:1:13 | = help: Add backslash to escape sequence diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_1.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_1.py.snap index 9e49faa22840e..8d763a16a3516 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_1.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_1.py.snap @@ -6,7 +6,7 @@ W605_1.py:4:11: W605 [*] Invalid escape sequence: `\.` 3 | #: W605:1:10 4 | regex = f'\.png$' | ^^ W605 -5 | +5 | 6 | #: W605:2:1 | = help: Use a raw string literal @@ -103,7 +103,7 @@ W605_1.py:25:40: W605 [*] Invalid escape sequence: `\_` W605_1.py:43:13: W605 [*] Invalid escape sequence: `\_` | 41 | ''' # noqa -42 | +42 | 43 | regex = f'\\\_' | ^^ W605 44 | value = f'\{{1}}' @@ -209,7 +209,7 @@ W605_1.py:48:15: W605 [*] Invalid escape sequence: `\{` 47 | value = f"{f"\{1}"}" 48 | value = rf"{f"\{1}"}" | ^^ W605 -49 | +49 | 50 | # Okay | = help: Use a raw string literal @@ -270,7 +270,7 @@ W605_1.py:59:12: W605 [*] Invalid escape sequence: `\d` 58 | f"\n{{}}+-\d+" 59 | f"\n{{}}�+-\d+" | ^^ W605 -60 | +60 | 61 | # See https://github.com/astral-sh/ruff/issues/11491 | = help: Add backslash to escape sequence @@ -291,7 +291,7 @@ W605_1.py:65:31: W605 [*] Invalid escape sequence: `\I` 64 | incomplete = 3 65 | s = f"TOTAL: {total}\nOK: {ok}\INCOMPLETE: {incomplete}\n" | ^^ W605 -66 | +66 | 67 | # Debug text (should trigger) | = help: Add backslash to escape sequence diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E302_notebook.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E302_notebook.snap index 057bf5f941b73..3a2fa4505d5eb 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E302_notebook.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E302_notebook.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E30.ipynb:21:1: E302 [*] Expected 2 blank lines, found 1 | 19 | pass -20 | +20 | 21 | def b(): | ^^^ E302 22 | pass diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E303_notebook.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E303_notebook.snap index ec883dae31334..2ccc9b5a562f4 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E303_notebook.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E303_notebook.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E30.ipynb:29:5: E303 [*] Too many blank lines (2) | 29 | # arbitrary comment | ^^^^^^^^^^^^^^^^^^^ E303 -30 | +30 | 31 | def inner(): # E306 not expected (pycodestyle detects E306) | = help: Remove extraneous blank line(s) diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E304_notebook.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E304_notebook.snap index 785066990f814..39fbc5b80fd4f 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E304_notebook.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E304_notebook.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E30.ipynb:45:1: E304 [*] Blank lines found after function decorator (1) | 43 | @decorator -44 | +44 | 45 | def function(): | ^^^ E304 46 | pass diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length.snap index c976d4c5f6400..a5c5cd23e79a0 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- W505.py:2:51: W505 Doc line too long (57 > 50) | @@ -14,17 +13,17 @@ W505.py:6:51: W505 Doc line too long (56 > 50) 5 | def f1(): 6 | """Here's a docstring that's also over the limit.""" | ^^^^^^ W505 -7 | +7 | 8 | x = 1 # Here's a comment that's over the limit, but it's not standalone. | W505.py:10:51: W505 Doc line too long (56 > 50) | 8 | x = 1 # Here's a comment that's over the limit, but it's not standalone. - 9 | + 9 | 10 | # Here's a standalone comment that's over the limit. | ^^^^^^ W505 -11 | +11 | 12 | x = 2 | @@ -33,7 +32,7 @@ W505.py:13:51: W505 Doc line too long (94 > 50) 12 | x = 2 13 | # Another standalone that is preceded by a newline and indent token and is over the limit. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 -14 | +14 | 15 | print("Here's a string that's over the limit, but it's not a docstring.") | @@ -46,7 +45,7 @@ W505.py:18:51: W505 Doc line too long (61 > 50) W505.py:24:51: W505 Doc line too long (82 > 50) | 22 | """Here's a multi-line docstring. -23 | +23 | 24 | It's over the limit on this line, which isn't the first line in the docstring. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 25 | """ @@ -55,7 +54,7 @@ W505.py:24:51: W505 Doc line too long (82 > 50) W505.py:31:51: W505 Doc line too long (85 > 50) | 29 | """Here's a multi-line docstring. -30 | +30 | 31 | It's over the limit on this line, which isn't the first line in the docstring.""" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length_with_utf_8.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length_with_utf_8.snap index 151742374cd52..64f4347ec6a75 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length_with_utf_8.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length_with_utf_8.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- W505_utf_8.py:2:50: W505 Doc line too long (57 > 50) | @@ -14,17 +13,17 @@ W505_utf_8.py:6:49: W505 Doc line too long (56 > 50) 5 | def f1(): 6 | """Here's a ß9💣2ℝing that's also over theß9💣2ℝ.""" | ^^^^^^ W505 -7 | +7 | 8 | x = 1 # Here's a comment that's over theß9💣2ℝ, but it's not standalone. | W505_utf_8.py:10:51: W505 Doc line too long (56 > 50) | 8 | x = 1 # Here's a comment that's over theß9💣2ℝ, but it's not standalone. - 9 | + 9 | 10 | # Here's a standalone comment that's over theß9💣2ℝ. | ^^^^^^ W505 -11 | +11 | 12 | x = 2 | @@ -33,7 +32,7 @@ W505_utf_8.py:13:51: W505 Doc line too long (94 > 50) 12 | x = 2 13 | # Another standalone that is preceded by a newline and indent token and is over theß9💣2ℝ. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 -14 | +14 | 15 | print("Here's a string that's over theß9💣2ℝ, but it's not a ß9💣2ℝing.") | @@ -46,7 +45,7 @@ W505_utf_8.py:18:50: W505 Doc line too long (61 > 50) W505_utf_8.py:24:50: W505 Doc line too long (82 > 50) | 22 | """Here's a multi-line ß9💣2ℝing. -23 | +23 | 24 | It's over theß9💣2ℝ on this line, which isn't the first line in the ß9💣2ℝing. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 25 | """ @@ -55,7 +54,7 @@ W505_utf_8.py:24:50: W505 Doc line too long (82 > 50) W505_utf_8.py:31:50: W505 Doc line too long (85 > 50) | 29 | """Here's a multi-line ß9💣2ℝing. -30 | +30 | 31 | It's over theß9💣2ℝ on this line, which isn't the first line in the ß9💣2ℝing.""" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__E502_E502.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__E502_E502.py.snap index d28418368a576..fe398c0aa1c30 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__E502_E502.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__E502_E502.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E502.py:9:9: E502 [*] Redundant backslash | 7 | + 4 - 8 | + 8 | 9 | a = (3 -\ | ^ E502 10 | 2 + \ @@ -247,7 +246,7 @@ E502.py:61:9: E502 [*] Redundant backslash E502.py:82:12: E502 [*] Redundant backslash | 80 | "xyz" -81 | +81 | 82 | x = ("abc" \ | ^ E502 83 | "xyz") diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_0.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_0.py.snap index 6007618c8572a..f6afa64ada9f7 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_0.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_0.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- W391_0.py:14:1: W391 [*] Extra newline at end of file | 12 | foo() 13 | bar() -14 | +14 | | ^ W391 | = help: Remove trailing newline diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_1.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_1.snap index ff6d0984c190f..2b5a0222b269d 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_1.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_1.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E501_2.py:2:7: E501 Line too long (7 > 6) | @@ -37,7 +36,7 @@ E501_2.py:10:7: E501 Line too long (7 > 6) 9 | # aa 10 | # aaa | ^ E501 -11 | +11 | 12 | if True: # noqa: E501 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_2.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_2.snap index 311ebe1d1e17b..bfc312b4dc544 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_2.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_2.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E501_2.py:2:7: E501 Line too long (7 > 6) | @@ -66,7 +65,7 @@ E501_2.py:10:5: E501 Line too long (9 > 6) 9 | # aa 10 | # aaa | ^^^ E501 -11 | +11 | 12 | if True: # noqa: E501 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_4.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_4.snap index f9a2e5c4f5c38..9930bcbee371e 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_4.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_4.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E501_2.py:2:7: E501 Line too long (7 > 6) | @@ -86,7 +85,7 @@ E501_2.py:10:3: E501 Line too long (13 > 6) 9 | # aa 10 | # aaa | ^^^^^ E501 -11 | +11 | 12 | if True: # noqa: E501 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_8.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_8.snap index b120644711fa8..2f3422d92f960 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_8.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_8.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E501_2.py:2:7: E501 Line too long (7 > 6) | @@ -86,7 +85,7 @@ E501_2.py:10:2: E501 Line too long (21 > 6) 9 | # aa 10 | # aaa | ^^^^^^^^^ E501 -11 | +11 | 12 | if True: # noqa: E501 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D101_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D101_D.py.snap index e61807f3cb9fd..c8cf6f9ab7532 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D101_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D101_D.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D.py:15:7: D101 Missing docstring in public class | 15 | class class_: | ^^^^^^ D101 -16 | +16 | 17 | expect('meta', 'D419: Docstring is empty') | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D107_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D107_D.py.snap index b3c6872247eb0..6fd782e2cee72 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D107_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D107_D.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D.py:60:9: D107 Missing docstring in `__init__` | @@ -13,7 +12,7 @@ D.py:60:9: D107 Missing docstring in `__init__` D.py:534:9: D107 Missing docstring in `__init__` | 532 | """ -533 | +533 | 534 | def __init__(self, x): | ^^^^^^^^ D107 535 | pass diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D202.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D202.py.snap index 5a4488570ec13..5d400736ed4a2 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D202.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D202.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D202.py:57:5: D202 [*] No blank lines allowed after function docstring (found 2) | @@ -46,7 +45,7 @@ D202.py:80:5: D202 [*] No blank lines allowed after function docstring (found 1) 79 | def outer(): 80 | """This is a docstring.""" | ^^^^^^^^^^^^^^^^^^^^^^^^^^ D202 -81 | +81 | 82 | # This is a comment. | = help: Remove blank line(s) after function docstring diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D204_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D204_D.py.snap index 12349f4b85d8c..8f7d860a3cfe1 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D204_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D204_D.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D.py:181:5: D204 [*] 1 blank line required after class docstring | 179 | class TrailingSpace: -180 | +180 | 181 | """TrailingSpace.""" | ^^^^^^^^^^^^^^^^^^^^ D204 182 | pass diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D211_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D211_D.py.snap index 35753cd8af2c5..affb5b409ec57 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D211_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D211_D.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D.py:170:5: D211 [*] No blank lines allowed before class docstring | 168 | class WithLeadingSpace: -169 | +169 | 170 | """With leading space.""" | ^^^^^^^^^^^^^^^^^^^^^^^^^ D211 | @@ -23,7 +22,7 @@ D.py:170:5: D211 [*] No blank lines allowed before class docstring D.py:181:5: D211 [*] No blank lines allowed before class docstring | 179 | class TrailingSpace: -180 | +180 | 181 | """TrailingSpace.""" | ^^^^^^^^^^^^^^^^^^^^ D211 182 | pass diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_D214_module.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_D214_module.py.snap index 31154618e43e3..dc344a0cc0918 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_D214_module.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_D214_module.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D214_module.py:3:5: D214 [*] Section is over-indented ("Returns") | 1 | """A module docstring with D214 violations -2 | +2 | 3 | Returns | ^^^^^^^ D214 4 | ----- @@ -25,7 +24,7 @@ D214_module.py:3:5: D214 [*] Section is over-indented ("Returns") D214_module.py:7:5: D214 [*] Section is over-indented ("Args") | 5 | valid returns -6 | +6 | 7 | Args | ^^^^ D214 8 | ----- diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_sections.py.snap index ae3e3a73f2cc8..371f690de1874 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_sections.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- sections.py:146:9: D214 [*] Section is over-indented ("Returns") | 144 | """Toggle the gizmo. -145 | +145 | 146 | Returns | ^^^^^^^ D214 147 | ------- @@ -26,7 +25,7 @@ sections.py:146:9: D214 [*] Section is over-indented ("Returns") sections.py:563:9: D214 [*] Section is over-indented ("Returns") | 561 | Here's a note. -562 | +562 | 563 | Returns: | ^^^^^^^ D214 564 | """ diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D402_D402.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D402_D402.py.snap index aa693f83977dc..1c23d91dc91d7 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D402_D402.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D402_D402.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D402.py:2:5: D402 First line should not be the function's signature | 1 | def foo(): 2 | """Returns foo().""" | ^^^^^^^^^^^^^^^^^^^^ D402 -3 | +3 | 4 | def foo(): | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D404_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D404_D.py.snap index a4e7ad8bae185..dec763cf08b64 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D404_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D404_D.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D.py:631:5: D404 First word of the docstring should not be "This" | @@ -22,14 +21,14 @@ D.py:639:17: D404 First word of the docstring should not be "This" | 639 | class SameLine: """This is a docstring on the same line""" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D404 -640 | +640 | 641 | def same_line(): """This is a docstring on the same line""" | D.py:641:18: D404 First word of the docstring should not be "This" | 639 | class SameLine: """This is a docstring on the same line""" -640 | +640 | 641 | def same_line(): """This is a docstring on the same line""" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D404 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D405_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D405_sections.py.snap index 2ec0f5de03340..840beb1830d34 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D405_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D405_sections.py.snap @@ -4,7 +4,7 @@ source: crates/ruff_linter/src/rules/pydocstyle/mod.rs sections.py:19:5: D405 [*] Section name should be properly capitalized ("returns") | 17 | """Toggle the gizmo. -18 | +18 | 19 | returns | ^^^^^^^ D405 20 | ------- @@ -25,7 +25,7 @@ sections.py:19:5: D405 [*] Section name should be properly capitalized ("returns sections.py:218:5: D405 [*] Section name should be properly capitalized ("Short summary") | 216 | """Toggle the gizmo. -217 | +217 | 218 | Short summary | ^^^^^^^^^^^^^ D405 219 | ------------- @@ -45,7 +45,7 @@ sections.py:218:5: D405 [*] Section name should be properly capitalized ("Short sections.py:573:5: D405 [*] Section name should be properly capitalized ("returns") | 571 | arg: Here's a note. -572 | +572 | 573 | returns: | ^^^^^^^ D405 574 | Here's another note. diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D406_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D406_sections.py.snap index 9a557902ae1bf..d5914e8da677d 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D406_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D406_sections.py.snap @@ -4,7 +4,7 @@ source: crates/ruff_linter/src/rules/pydocstyle/mod.rs sections.py:32:5: D406 [*] Section name should end with a newline ("Returns") | 30 | """Toggle the gizmo. -31 | +31 | 32 | Returns: | ^^^^^^^ D406 33 | ------- @@ -45,7 +45,7 @@ sections.py:227:5: D406 [*] Section name should end with a newline ("Raises") sections.py:601:5: D406 [*] Section name should end with a newline ("Parameters") | 599 | """Test that lower case subsection header is valid even if it has the same name as section kind. -600 | +600 | 601 | Parameters: | ^^^^^^^^^^ D406 602 | ---------- diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D407_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D407_sections.py.snap index 91865707578f9..767809f849287 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D407_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D407_sections.py.snap @@ -4,7 +4,7 @@ source: crates/ruff_linter/src/rules/pydocstyle/mod.rs sections.py:44:5: D407 [*] Missing dashed underline after section ("Returns") | 42 | """Toggle the gizmo. -43 | +43 | 44 | Returns | ^^^^^^^ D407 45 | A value of some sort. @@ -23,10 +23,10 @@ sections.py:44:5: D407 [*] Missing dashed underline after section ("Returns") sections.py:56:5: D407 [*] Missing dashed underline after section ("Returns") | 54 | """Toggle the gizmo. -55 | +55 | 56 | Returns | ^^^^^^^ D407 -57 | +57 | 58 | """ | = help: Add dashed line under "Returns" @@ -43,7 +43,7 @@ sections.py:56:5: D407 [*] Missing dashed underline after section ("Returns") sections.py:67:5: D407 [*] Missing dashed underline after section ("Returns") | 65 | """Toggle the gizmo. -66 | +66 | 67 | Returns""" | ^^^^^^^ D407 | @@ -120,7 +120,7 @@ sections.py:530:5: D407 [*] Missing dashed underline after section ("Parameters" sections.py:613:4: D407 [*] Missing dashed underline after section ("Parameters") | 611 | """Test that lower case subsection header is valid even if it is of a different kind. -612 | +612 | 613 | Parameters | ^^^^^^^^^^ D407 614 | -‐----------------- diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D408_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D408_sections.py.snap index 843296208e9f1..2bb4847569e0b 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D408_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D408_sections.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- sections.py:98:5: D408 [*] Section underline should be in the line following the section's name ("Returns") | 96 | Returns -97 | +97 | 98 | ------- | ^^^^^^^ D408 99 | A value of some sort. diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_D410.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_D410.py.snap index dd457b879659e..f95ac4dd1f4fb 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_D410.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_D410.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D410.py:4:5: D410 [*] Missing blank line after section ("Parameters") | 2 | """Showcase function. -3 | +3 | 4 | Parameters | ^^^^^^^^^^ D410 5 | ---------- @@ -25,7 +24,7 @@ D410.py:4:5: D410 [*] Missing blank line after section ("Parameters") D410.py:21:5: D410 [*] Missing blank line after section ("Parameters") | 19 | """Showcase function. -20 | +20 | 21 | Parameters | ^^^^^^^^^^ D410 22 | ---------- diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_sections.py.snap index 246475689e705..389391bb4665c 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_sections.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- sections.py:78:5: D410 [*] Missing blank line after section ("Returns") | 76 | """Toggle the gizmo. -77 | +77 | 78 | Returns | ^^^^^^^ D410 79 | ------- @@ -25,7 +24,7 @@ sections.py:78:5: D410 [*] Missing blank line after section ("Returns") sections.py:224:5: D410 [*] Missing blank line after section ("Returns") | 222 | returns. -223 | +223 | 224 | Returns | ^^^^^^^ D410 225 | ------ diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sections.py.snap index 8f48cccc69359..6616be7a6ec69 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sections.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- sections.py:218:5: D412 [*] No blank lines allowed between a section header and its content ("Short summary") | 216 | """Toggle the gizmo. -217 | +217 | 218 | Short summary | ^^^^^^^^^^^^^ D412 219 | ------------- diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_D413.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_D413.py.snap index 7aa16a9e29825..d1339c1a8a46c 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_D413.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_D413.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D413.py:7:1: D413 [*] Missing blank line after last section ("Returns") | 5 | with a hanging indent -6 | +6 | 7 | Returns: | ^^^^^^^ D413 8 | the value @@ -25,7 +24,7 @@ D413.py:7:1: D413 [*] Missing blank line after last section ("Returns") D413.py:19:5: D413 [*] Missing blank line after last section ("Returns") | 17 | with a hanging indent -18 | +18 | 19 | Returns: | ^^^^^^^ D413 20 | the value @@ -45,7 +44,7 @@ D413.py:19:5: D413 [*] Missing blank line after last section ("Returns") D413.py:58:5: D413 [*] Missing blank line after last section ("Returns") | 56 | with a hanging indent -57 | +57 | 58 | Returns: | ^^^^^^^ D413 59 | the value""" @@ -67,7 +66,7 @@ D413.py:58:5: D413 [*] Missing blank line after last section ("Returns") D413.py:69:5: D413 [*] Missing blank line after last section ("Returns") | 67 | with a hanging indent -68 | +68 | 69 | Returns: | ^^^^^^^ D413 70 | the value diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_sections.py.snap index 9e32aa1a2339f..c8e9fd19ae22e 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_sections.py.snap @@ -4,7 +4,7 @@ source: crates/ruff_linter/src/rules/pydocstyle/mod.rs sections.py:67:5: D413 [*] Missing blank line after last section ("Returns") | 65 | """Toggle the gizmo. -66 | +66 | 67 | Returns""" | ^^^^^^^ D413 | @@ -25,7 +25,7 @@ sections.py:67:5: D413 [*] Missing blank line after last section ("Returns") sections.py:122:5: D413 [*] Missing blank line after last section ("Returns") | 120 | """Toggle the gizmo. -121 | +121 | 122 | Returns | ^^^^^^^ D413 123 | ------- @@ -45,7 +45,7 @@ sections.py:122:5: D413 [*] Missing blank line after last section ("Returns") sections.py:172:5: D413 [*] Missing blank line after last section ("Returns") | 170 | """Toggle the gizmo. -171 | +171 | 172 | Returns | ^^^^^^^ D413 173 | ------- @@ -65,7 +65,7 @@ sections.py:172:5: D413 [*] Missing blank line after last section ("Returns") sections.py:521:5: D413 [*] Missing blank line after last section ("Parameters") | 519 | """Equal length equals should be replaced with dashes. -520 | +520 | 521 | Parameters | ^^^^^^^^^^ D413 522 | ========== @@ -85,7 +85,7 @@ sections.py:521:5: D413 [*] Missing blank line after last section ("Parameters") sections.py:529:5: D413 [*] Missing blank line after last section ("Parameters") | 527 | """Here, the length of equals is not the same. -528 | +528 | 529 | Parameters | ^^^^^^^^^^ D413 530 | =========== @@ -105,7 +105,7 @@ sections.py:529:5: D413 [*] Missing blank line after last section ("Parameters") sections.py:550:5: D413 [*] Missing blank line after last section ("Args") | 548 | """Below, `returns:` should _not_ be considered a section header. -549 | +549 | 550 | Args: | ^^^^ D413 551 | Here's a note. @@ -124,7 +124,7 @@ sections.py:550:5: D413 [*] Missing blank line after last section ("Args") sections.py:563:9: D413 [*] Missing blank line after last section ("Returns") | 561 | Here's a note. -562 | +562 | 563 | Returns: | ^^^^^^^ D413 564 | """ @@ -143,7 +143,7 @@ sections.py:563:9: D413 [*] Missing blank line after last section ("Returns") sections.py:573:5: D413 [*] Missing blank line after last section ("returns") | 571 | arg: Here's a note. -572 | +572 | 573 | returns: | ^^^^^^^ D413 574 | Here's another note. @@ -163,7 +163,7 @@ sections.py:573:5: D413 [*] Missing blank line after last section ("returns") sections.py:601:5: D413 [*] Missing blank line after last section ("Parameters") | 599 | """Test that lower case subsection header is valid even if it has the same name as section kind. -600 | +600 | 601 | Parameters: | ^^^^^^^^^^ D413 602 | ---------- diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D414_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D414_sections.py.snap index c50a27623f289..c4cfd3cd33ba3 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D414_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D414_sections.py.snap @@ -1,21 +1,20 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- sections.py:56:5: D414 Section has no content ("Returns") | 54 | """Toggle the gizmo. -55 | +55 | 56 | Returns | ^^^^^^^ D414 -57 | +57 | 58 | """ | sections.py:67:5: D414 Section has no content ("Returns") | 65 | """Toggle the gizmo. -66 | +66 | 67 | Returns""" | ^^^^^^^ D414 | @@ -23,7 +22,7 @@ sections.py:67:5: D414 Section has no content ("Returns") sections.py:78:5: D414 Section has no content ("Returns") | 76 | """Toggle the gizmo. -77 | +77 | 78 | Returns | ^^^^^^^ D414 79 | ------- @@ -42,7 +41,7 @@ sections.py:80:5: D414 Section has no content ("Yields") sections.py:172:5: D414 Section has no content ("Returns") | 170 | """Toggle the gizmo. -171 | +171 | 172 | Returns | ^^^^^^^ D414 173 | ------- @@ -52,17 +51,17 @@ sections.py:172:5: D414 Section has no content ("Returns") sections.py:266:5: D414 Section has no content ("Returns") | 264 | note: A random string. -265 | +265 | 266 | Returns: | ^^^^^^^ D414 -267 | +267 | 268 | Raises: | sections.py:563:9: D414 Section has no content ("Returns") | 561 | Here's a note. -562 | +562 | 563 | Returns: | ^^^^^^^ D414 564 | """ diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D417_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D417_sections.py.snap index ffc17f2005318..17d957fa2befb 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D417_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D417_sections.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- sections.py:292:9: D417 Missing argument description in the docstring for `bar`: `y` | 290 | x = 1 -291 | +291 | 292 | def bar(y=2): # noqa: D207, D213, D406, D407 | ^^^ D417 293 | """Nested function test for docstrings. diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D419_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D419_D.py.snap index 6775b85826503..18f659a0c5c96 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D419_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D419_D.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D.py:20:9: D419 Docstring is empty | 19 | class meta: 20 | """""" | ^^^^^^ D419 -21 | +21 | 22 | @expect('D102: Missing docstring in public method') | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_google.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_google.snap index 38a96aa54c0af..4d728dac52133 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_google.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_google.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D417.py:1:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` | @@ -76,7 +75,7 @@ D417.py:155:5: D417 Missing argument description in the docstring for `select_da D417.py:172:5: D417 Missing argument description in the docstring for `f`: `**kwargs` | 170 | """ -171 | +171 | 172 | def f(x, *args, **kwargs): | ^ D417 173 | """Do something. diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_unspecified.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_unspecified.snap index 38a96aa54c0af..4d728dac52133 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_unspecified.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_unspecified.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D417.py:1:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` | @@ -76,7 +75,7 @@ D417.py:155:5: D417 Missing argument description in the docstring for `select_da D417.py:172:5: D417 Missing argument description in the docstring for `f`: `**kwargs` | 170 | """ -171 | +171 | 172 | def f(x, *args, **kwargs): | ^ D417 173 | """Do something. diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_unspecified_ignore_var_parameters.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_unspecified_ignore_var_parameters.snap index 38a96aa54c0af..4d728dac52133 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_unspecified_ignore_var_parameters.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_unspecified_ignore_var_parameters.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D417.py:1:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` | @@ -76,7 +75,7 @@ D417.py:155:5: D417 Missing argument description in the docstring for `select_da D417.py:172:5: D417 Missing argument description in the docstring for `f`: `**kwargs` | 170 | """ -171 | +171 | 172 | def f(x, *args, **kwargs): | ^ D417 173 | """Do something. diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_0.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_0.py.snap index b77ae8d19f8e3..386a6e2892afb 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_0.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_0.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F401_0.py:2:8: F401 [*] `functools` imported but unused | @@ -84,7 +83,7 @@ F401_0.py:33:12: F401 [*] `importlib` imported but unused 32 | import shelve 33 | import importlib | ^^^^^^^^^ F401 -34 | +34 | 35 | if TYPE_CHECKING: | = help: Remove unused import: `importlib` @@ -104,7 +103,7 @@ F401_0.py:37:12: F401 [*] `pathlib` imported but unused 36 | """Hello, world!""" 37 | import pathlib | ^^^^^^^ F401 -38 | +38 | 39 | z = 1 | = help: Remove unused import: `pathlib` @@ -179,7 +178,7 @@ F401_0.py:99:8: F401 [*] `foo.bar.baz` imported but unused 98 | import foo.bar as bop 99 | import foo.bar.baz | ^^^^^^^^^^^ F401 -100 | +100 | 101 | print(bop.baz.read_csv("test.csv")) | = help: Remove unused import: `foo.bar.baz` @@ -199,7 +198,7 @@ F401_0.py:105:12: F401 [*] `a1` imported but unused 104 | if TYPE_CHECKING: 105 | import a1 | ^^ F401 -106 | +106 | 107 | import a2 | = help: Remove unused import: `a1` @@ -216,7 +215,7 @@ F401_0.py:105:12: F401 [*] `a1` imported but unused F401_0.py:107:12: F401 [*] `a2` imported but unused | 105 | import a1 -106 | +106 | 107 | import a2 | ^^ F401 | @@ -237,7 +236,7 @@ F401_0.py:112:16: F401 [*] `b1` imported but unused 111 | case 0,: 112 | import b1 | ^^ F401 -113 | +113 | 114 | import b2 | = help: Remove unused import: `b1` @@ -254,7 +253,7 @@ F401_0.py:112:16: F401 [*] `b1` imported but unused F401_0.py:114:16: F401 [*] `b2` imported but unused | 112 | import b1 -113 | +113 | 114 | import b2 | ^^ F401 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_10.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_10.py.snap index a6748658a16f1..55ff498a0534d 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_10.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_10.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F401_10.py:6:16: F401 `orjson` imported but unused; consider using `importlib.util.find_spec` to test for availability | @@ -8,7 +7,7 @@ F401_10.py:6:16: F401 `orjson` imported but unused; consider using `importlib.ut 5 | try: 6 | import orjson | ^^^^^^ F401 -7 | +7 | 8 | return True | = help: Remove unused import: `orjson` @@ -19,7 +18,7 @@ F401_10.py:15:16: F401 `orjson` imported but unused; consider using `importlib.u 14 | try: 15 | import orjson | ^^^^^^ F401 -16 | +16 | 17 | return True | = help: Remove unused import: `orjson` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_17.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_17.py.snap index 7bf797d3cdd71..24a1dc4ff184d 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_17.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_17.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F401_17.py:12:27: F401 [*] `threading.Thread` imported but unused | 11 | def fn(thread: Thread): 12 | from threading import Thread | ^^^^^^ F401 -13 | +13 | 14 | # The `Thread` on the left-hand side should resolve to the `Thread` imported at the | = help: Remove unused import: `threading.Thread` @@ -26,7 +25,7 @@ F401_17.py:20:27: F401 [*] `threading.Thread` imported but unused 19 | def fn(thread: Thread): 20 | from threading import Thread | ^^^^^^ F401 -21 | +21 | 22 | # The `Thread` on the left-hand side should resolve to the `Thread` imported at the | = help: Remove unused import: `threading.Thread` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_6.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_6.py.snap index 84a4897835008..24dbe932b4c5a 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_6.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_6.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F401_6.py:7:25: F401 [*] `.background.BackgroundTasks` imported but unused | 6 | # F401 `background.BackgroundTasks` imported but unused 7 | from .background import BackgroundTasks | ^^^^^^^^^^^^^^^ F401 -8 | +8 | 9 | # F401 `datastructures.UploadFile` imported but unused | = help: Remove unused import: `.background.BackgroundTasks` @@ -26,7 +25,7 @@ F401_6.py:10:43: F401 [*] `.datastructures.UploadFile` imported but unused 9 | # F401 `datastructures.UploadFile` imported but unused 10 | from .datastructures import UploadFile as FileUpload | ^^^^^^^^^^ F401 -11 | +11 | 12 | # OK | = help: Remove unused import: `.datastructures.UploadFile` @@ -45,7 +44,7 @@ F401_6.py:16:8: F401 [*] `background` imported but unused 15 | # F401 `background` imported but unused 16 | import background | ^^^^^^^^^^ F401 -17 | +17 | 18 | # F401 `datastructures` imported but unused | = help: Remove unused import: `background` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_29__all_conditional____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_29__all_conditional____init__.py.snap index 515ca60e48951..be576ca11c1f0 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_29__all_conditional____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_29__all_conditional____init__.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- __init__.py:8:15: F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | 6 | import sys - 7 | + 7 | 8 | from . import unused, exported, renamed as bees | ^^^^^^ F401 - 9 | + 9 | 10 | if sys.version_info > (3, 9): | = help: Remove unused import @@ -26,10 +25,10 @@ __init__.py:8:15: F401 [*] `.unused` imported but unused; consider removing, add __init__.py:8:44: F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | 6 | import sys - 7 | + 7 | 8 | from . import unused, exported, renamed as bees | ^^^^ F401 - 9 | + 9 | 10 | if sys.version_info > (3, 9): | = help: Remove unused import diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_30.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_30.py.snap index 75c2e0795a1cf..f65dc78b598ef 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_30.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_30.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F401_30.py:6:19: F401 [*] `.main.MaμToMan` imported but unused | 4 | """ -5 | +5 | 6 | from .main import MaµToMan | ^^^^^^^^ F401 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_29__all_conditional____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_29__all_conditional____init__.py.snap index 324c57b7600c0..57c17bb0c551c 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_29__all_conditional____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_29__all_conditional____init__.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- __init__.py:8:15: F401 `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | 6 | import sys - 7 | + 7 | 8 | from . import unused, exported, renamed as bees | ^^^^^^ F401 - 9 | + 9 | 10 | if sys.version_info > (3, 9): | = help: Remove unused import @@ -16,10 +15,10 @@ __init__.py:8:15: F401 `.unused` imported but unused; consider removing, adding __init__.py:8:44: F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | 6 | import sys - 7 | + 7 | 8 | from . import unused, exported, renamed as bees | ^^^^ F401 - 9 | + 9 | 10 | if sys.version_info > (3, 9): | = help: Remove unused import diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F402_F402.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F402_F402.py.snap index cb4dcbad83870..b6c04ece22bfb 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F402_F402.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F402_F402.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F402.py:5:5: F402 Import `os` from line 1 shadowed by loop variable | @@ -12,7 +11,7 @@ F402.py:5:5: F402 Import `os` from line 1 shadowed by loop variable F402.py:8:5: F402 Import `path` from line 2 shadowed by loop variable | 6 | pass -7 | +7 | 8 | for path in range(3): | ^^^^ F402 9 | pass diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F403_F403.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F403_F403.py.snap index 6b283ac329886..954899e12a603 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F403_F403.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F403_F403.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F403.py:1:1: F403 `from F634 import *` used; unable to detect undefined names | @@ -14,6 +13,6 @@ F403.py:2:1: F403 `from F634 import *` used; unable to detect undefined names 1 | from F634 import * 2 | from F634 import * # noqa: E501 | ^^^^^^^^^^^^^^^^^^ F403 -3 | +3 | 4 | from F634 import * # noqa | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F404_F404_0.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F404_F404_0.py.snap index 48f04fc13f1c6..0e5776e9b3eca 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F404_F404_0.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F404_F404_0.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F404_0.py:6:1: F404 `from __future__` imports must occur at the beginning of the file | 4 | from collections import namedtuple -5 | +5 | 6 | from __future__ import print_function | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F404 -7 | +7 | 8 | import __future__ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F404_F404_1.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F404_F404_1.py.snap index 22dc7a5bab360..533b95b9a7530 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F404_F404_1.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F404_F404_1.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F404_1.py:5:1: F404 `from __future__` imports must occur at the beginning of the file | 3 | """Non-docstring""" -4 | +4 | 5 | from __future__ import absolute_import | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F404 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F405_F405.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F405_F405.py.snap index 892e99f850656..566ebc15bbb7b 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F405_F405.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F405_F405.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F405.py:5:11: F405 `name` may be undefined, or defined from star imports | @@ -12,7 +11,7 @@ F405.py:5:11: F405 `name` may be undefined, or defined from star imports F405.py:11:12: F405 `a` may be undefined, or defined from star imports | 9 | print(name) -10 | +10 | 11 | __all__ = ['a'] | ^^^ F405 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F504.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F504.py.snap index 31e02878d310e..270e0e25a5957 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F504.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F504.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F504.py:3:1: F504 [*] `%`-format string has unused named argument(s): b | @@ -8,7 +7,7 @@ F504.py:3:1: F504 [*] `%`-format string has unused named argument(s): b 2 | a = "wrong" 3 | "%(a)s %(c)s" % {a: "?", "b": "!"} # F504 ("b" not used) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F504 -4 | +4 | 5 | hidden = {"a": "!"} | = help: Remove extra named arguments: b @@ -25,7 +24,7 @@ F504.py:3:1: F504 [*] `%`-format string has unused named argument(s): b F504.py:8:1: F504 [*] `%`-format string has unused named argument(s): b | 6 | "%(a)s %(c)s" % {"x": 1, **hidden} # Ok (cannot see through splat) -7 | +7 | 8 | "%(a)s" % {"a": 1, r"b": "!"} # F504 ("b" not used) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F504 9 | "%(a)s" % {'a': 1, u"b": "!"} # F504 ("b" not used) @@ -47,7 +46,7 @@ F504.py:9:1: F504 [*] `%`-format string has unused named argument(s): b 8 | "%(a)s" % {"a": 1, r"b": "!"} # F504 ("b" not used) 9 | "%(a)s" % {'a': 1, u"b": "!"} # F504 ("b" not used) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F504 -10 | +10 | 11 | '' % {'a''b' : ''} # F504 ("ab" not used) | = help: Remove extra named arguments: b @@ -65,10 +64,10 @@ F504.py:9:1: F504 [*] `%`-format string has unused named argument(s): b F504.py:11:1: F504 [*] `%`-format string has unused named argument(s): ab | 9 | "%(a)s" % {'a': 1, u"b": "!"} # F504 ("b" not used) -10 | +10 | 11 | '' % {'a''b' : ''} # F504 ("ab" not used) | ^^^^^^^^^^^^^^^^^^ F504 -12 | +12 | 13 | # https://github.com/astral-sh/ruff/issues/4899 | = help: Remove extra named arguments: ab diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F506_F50x.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F506_F50x.py.snap index bcb4e836ddcd7..8014d22098227 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F506_F50x.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F506_F50x.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F50x.py:2:1: F506 `%`-format string has mixed positional and named placeholders | @@ -27,6 +26,6 @@ F50x.py:11:1: F506 `%`-format string has mixed positional and named placeholders 10 | '%s %s' % {'k': 'v'} # F503 11 | '%(bar)*s' % {'bar': 'baz'} # F506, F508 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ F506 -12 | +12 | 13 | # ok: single %s with mapping | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F508_F50x.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F508_F50x.py.snap index 5689f463137c1..b4415123436ed 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F508_F50x.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F508_F50x.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F50x.py:11:1: F508 `%`-format string `*` specifier requires sequence | @@ -8,6 +7,6 @@ F50x.py:11:1: F508 `%`-format string `*` specifier requires sequence 10 | '%s %s' % {'k': 'v'} # F503 11 | '%(bar)*s' % {'bar': 'baz'} # F506, F508 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ F508 -12 | +12 | 13 | # ok: single %s with mapping | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F521_F521.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F521_F521.py.snap index 063e654867b07..c9f840f58a885 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F521_F521.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F521_F521.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F521.py:1:1: F521 `.format` call has invalid format string: Single '{' encountered in format string | @@ -64,6 +63,6 @@ F521.py:9:1: F521 `.format` call has invalid format string: Empty attribute in f 8 | "{foo..}".format(foo=1) 9 | "{foo..bar}".format(foo=1) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ F521 -10 | +10 | 11 | # The following are all "good" uses of .format | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F523_F523.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F523_F523.py.snap index b072d35ab095b..5b882fb4c6dfe 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F523_F523.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F523_F523.py.snap @@ -77,7 +77,7 @@ F523.py:7:1: F523 `.format` call has unused arguments at position(s): 0, 3 6 | "{0}{2}".format(1, 2) # F523, # F524 7 | "{1.arg[1]!r:0{2['arg']}{1}}".format(1, 2, 3, 4) # F523 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F523 -8 | +8 | 9 | # With no indexes | = help: Remove extra positional arguments at position(s): 0, 3 @@ -129,7 +129,7 @@ F523.py:13:1: F523 [*] `.format` call has unused arguments at position(s): 2 12 | "{:{}}".format(1, 2) # No issues 13 | "{:{}}".format(1, 2, 3) # F523 | ^^^^^^^^^^^^^^^^^^^^^^^ F523 -14 | +14 | 15 | # With *args | = help: Remove extra positional arguments at position(s): 2 @@ -150,7 +150,7 @@ F523.py:19:1: F523 `.format` call has unused arguments at position(s): 2 18 | "{0}{1}".format(1, 2, *args) # No issues 19 | "{0}{1}".format(1, 2, 3, *args) # F523 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F523 -20 | +20 | 21 | # With nested quotes | = help: Remove extra positional arguments at position(s): 2 @@ -201,7 +201,7 @@ F523.py:24:1: F523 [*] `.format` call has unused arguments at position(s): 2 23 | "\"\"{1}{0}".format(1, 2, 3) # F523 24 | '""{1}{0}'.format(1, 2, 3) # F523 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ F523 -25 | +25 | 26 | # With modified indexes | = help: Remove extra positional arguments at position(s): 2 @@ -242,7 +242,7 @@ F523.py:29:1: F523 `.format` call has unused arguments at position(s): 0 28 | "{1}{3}".format(1, 2, 3, 4) # F523, # F524 29 | "{1} {8}".format(0, 1) # F523, # F524 | ^^^^^^^^^^^^^^^^^^^^^^ F523 -30 | +30 | 31 | # Multiline | = help: Remove extra positional arguments at position(s): 0 @@ -254,7 +254,7 @@ F523.py:32:2: F523 [*] `.format` call has unused arguments at position(s): 0 | __^ 33 | | .format(2)) | |__________^ F523 -34 | +34 | 35 | # Removing the final argument. | = help: Remove extra positional arguments at position(s): 0 diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F541_F541.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F541_F541.py.snap index cd2143101b7de..a7938d42abdb0 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F541_F541.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F541_F541.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F541.py:6:5: F541 [*] f-string without any placeholders | @@ -154,7 +153,7 @@ F541.py:19:5: F541 [*] f-string without any placeholders 18 | ) 19 | g = f"" | ^^^ F541 -20 | +20 | 21 | # OK | = help: Remove extraneous `f` prefix @@ -174,7 +173,7 @@ F541.py:25:13: F541 [*] f-string without any placeholders 24 | # Error 25 | h = "x" "y" f"z" | ^^^^ F541 -26 | +26 | 27 | v = 23.234234 | = help: Remove extraneous `f` prefix diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F601_F601.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F601_F601.py.snap index 5e9c377de1841..b16b7bea64547 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F601_F601.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F601_F601.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F601.py:3:5: F601 Dictionary key literal `"a"` repeated | @@ -246,7 +245,7 @@ F601.py:45:5: F601 [*] Dictionary key literal `"a"` repeated F601.py:49:14: F601 [*] Dictionary key literal `"a"` repeated | 47 | } -48 | +48 | 49 | x = {"a": 1, "a": 1} | ^^^ F601 50 | x = {"a": 1, "b": 2, "a": 1} @@ -268,7 +267,7 @@ F601.py:50:22: F601 [*] Dictionary key literal `"a"` repeated 49 | x = {"a": 1, "a": 1} 50 | x = {"a": 1, "b": 2, "a": 1} | ^^^ F601 -51 | +51 | 52 | x = { | = help: Remove repeated key literal `"a"` @@ -298,7 +297,7 @@ F601.py:58:19: F601 [*] Dictionary key literal `"x"` repeated 57 | # Regression test for: https://github.com/astral-sh/ruff/issues/4897 58 | t={"x":"test123", "x":("test123")} | ^^^ F601 -59 | +59 | 60 | t={"x":("test123"), "x":"test123"} | = help: Remove repeated key literal `"x"` @@ -316,10 +315,10 @@ F601.py:58:19: F601 [*] Dictionary key literal `"x"` repeated F601.py:60:21: F601 [*] Dictionary key literal `"x"` repeated | 58 | t={"x":"test123", "x":("test123")} -59 | +59 | 60 | t={"x":("test123"), "x":"test123"} | ^^^ F601 -61 | +61 | 62 | # Regression test for: https://github.com/astral-sh/ruff/issues/12772 | = help: Remove repeated key literal `"x"` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F602_F602.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F602_F602.py.snap index 434d700c8e035..6fe76f9fd026f 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F602_F602.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F602_F602.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F602.py:5:5: F602 Dictionary key `a` repeated | @@ -213,7 +212,7 @@ F602.py:41:5: F602 Dictionary key `a` repeated F602.py:44:12: F602 [*] Dictionary key `a` repeated | 42 | } -43 | +43 | 44 | x = {a: 1, a: 1} | ^ F602 45 | x = {a: 1, b: 2, a: 1} diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F632_F632.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F632_F632.py.snap index 0e34699876329..0bf2cf432b361 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F632_F632.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F632_F632.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F632.py:1:4: F632 [*] Use `==` to compare constant literals | @@ -20,7 +19,7 @@ F632.py:1:4: F632 [*] Use `==` to compare constant literals F632.py:4:4: F632 [*] Use `!=` to compare constant literals | 2 | pass -3 | +3 | 4 | if 123 is not y: | ^^^^^^^^^^^^ F632 5 | pass @@ -40,7 +39,7 @@ F632.py:4:4: F632 [*] Use `!=` to compare constant literals F632.py:7:4: F632 [*] Use `!=` to compare constant literals | 5 | pass -6 | +6 | 7 | if 123 is \ | ____^ 8 | | not y: @@ -63,7 +62,7 @@ F632.py:7:4: F632 [*] Use `!=` to compare constant literals F632.py:11:4: F632 [*] Use `==` to compare constant literals | 9 | pass -10 | +10 | 11 | if "123" is x < 3: | ^^^^^^^^^^^^^^ F632 12 | pass @@ -83,7 +82,7 @@ F632.py:11:4: F632 [*] Use `==` to compare constant literals F632.py:14:4: F632 [*] Use `==` to compare constant literals | 12 | pass -13 | +13 | 14 | if "123" != x is 3: | ^^^^^^^^^^^^^^^ F632 15 | pass @@ -103,7 +102,7 @@ F632.py:14:4: F632 [*] Use `==` to compare constant literals F632.py:17:4: F632 [*] Use `==` to compare constant literals | 15 | pass -16 | +16 | 17 | if ("123" != x) is 3: | ^^^^^^^^^^^^^^^^^ F632 18 | pass @@ -123,7 +122,7 @@ F632.py:17:4: F632 [*] Use `==` to compare constant literals F632.py:20:14: F632 [*] Use `==` to compare constant literals | 18 | pass -19 | +19 | 20 | if "123" != (x is 3): | ^^^^^^ F632 21 | pass @@ -143,12 +142,12 @@ F632.py:20:14: F632 [*] Use `==` to compare constant literals F632.py:23:2: F632 [*] Use `!=` to compare constant literals | 21 | pass -22 | +22 | 23 | {2 is | __^ 24 | | not ''} | |______^ F632 -25 | +25 | 26 | {2 is | = help: Replace `is not` with `!=` @@ -167,12 +166,12 @@ F632.py:23:2: F632 [*] Use `!=` to compare constant literals F632.py:26:2: F632 [*] Use `!=` to compare constant literals | 24 | not ''} -25 | +25 | 26 | {2 is | __^ 27 | | not ''} | |_______^ F632 -28 | +28 | 29 | # Regression test for | = help: Replace `is not` with `!=` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F633_F633.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F633_F633.py.snap index cdd978829918d..1399617c01a3c 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F633_F633.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F633_F633.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F633.py:4:1: F633 Use of `>>` is invalid with `print` function | 2 | import sys -3 | +3 | 4 | print >> sys.stderr, "Hello" | ^^^^^ F633 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F634_F634.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F634_F634.py.snap index 3f9eda1a9c18a..ce4f4be9aafdf 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F634_F634.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F634_F634.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F634.py:1:4: F634 If test is a tuple, which is always `True` | @@ -12,7 +11,7 @@ F634.py:1:4: F634 If test is a tuple, which is always `True` F634.py:4:4: F634 If test is a tuple, which is always `True` | 2 | pass -3 | +3 | 4 | if (3, 4): | ^^^^^^ F634 5 | pass diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F701_F701.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F701_F701.py.snap index 23be6d89644ce..775b955209440 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F701_F701.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F701_F701.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F701.py:4:5: F701 `break` outside loop | @@ -8,14 +7,14 @@ F701.py:4:5: F701 `break` outside loop 3 | else: 4 | break | ^^^^^ F701 -5 | +5 | 6 | i = 0 | F701.py:16:5: F701 `break` outside loop | 14 | break -15 | +15 | 16 | break | ^^^^^ F701 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F702_F702.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F702_F702.py.snap index a656678f6b4fe..89f8fd3cc0886 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F702_F702.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F702_F702.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F702.py:4:5: F702 `continue` not properly in loop | @@ -8,14 +7,14 @@ F702.py:4:5: F702 `continue` not properly in loop 3 | else: 4 | continue | ^^^^^^^^ F702 -5 | +5 | 6 | i = 0 | F702.py:16:5: F702 `continue` not properly in loop | 14 | continue -15 | +15 | 16 | continue | ^^^^^^^^ F702 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_17.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_17.py.snap index 15891fcb425f7..367f5873a091f 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_17.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_17.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F811_17.py:6:12: F811 [*] Redefinition of unused `fu` from line 2 | 5 | def bar(): 6 | import fu | ^^ F811 -7 | +7 | 8 | def baz(): | = help: Remove definition: `fu` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_26.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_26.py.snap index aff6b40d4dbd0..91cacac98d4f2 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_26.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_26.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F811_26.py:5:9: F811 Redefinition of unused `func` from line 2 | 3 | pass -4 | +4 | 5 | def func(self): | ^^^^ F811 6 | pass diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_28.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_28.py.snap index c8d46f2b0f862..69b2869a43dea 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_28.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_28.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F811_28.py:4:22: F811 Redefinition of unused `datetime` from line 3 | 3 | import datetime 4 | from datetime import datetime | ^^^^^^^^ F811 -5 | +5 | 6 | datetime(1, 2, 3) | = help: Remove definition: `datetime` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_29.pyi.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_29.pyi.snap index dfe89ac980585..b67239e5d446e 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_29.pyi.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_29.pyi.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F811_29.pyi:8:1: F811 Redefinition of unused `Bar` from line 3 | 6 | Bar: int # OK -7 | +7 | 8 | Bar = 1 # F811 | ^^^ F811 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_30.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_30.py.snap index 68319f4244e84..b2955d60750cd 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_30.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_30.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F811_30.py:12:9: F811 Redefinition of unused `bar` from line 10 | 10 | bar = foo -11 | +11 | 12 | def bar(self) -> None: | ^^^ F811 13 | """Bar.""" @@ -15,7 +14,7 @@ F811_30.py:12:9: F811 Redefinition of unused `bar` from line 10 F811_30.py:21:5: F811 Redefinition of unused `baz` from line 18 | 19 | """Baz.""" -20 | +20 | 21 | baz = 1 | ^^^ F811 | @@ -24,7 +23,7 @@ F811_30.py:21:5: F811 Redefinition of unused `baz` from line 18 F811_30.py:29:12: F811 Redefinition of unused `foo` from line 26 | 27 | """Foo.""" -28 | +28 | 29 | bar = (foo := 1) | ^^^ F811 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_31.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_31.py.snap index 439eae473aef7..bb4eb97b10a44 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_31.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_31.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F811_31.py:19:29: F811 Redefinition of unused `baz` from line 17 | 17 | baz = None -18 | +18 | 19 | from some_module import baz | ^^^ F811 20 | except ImportError: diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_0.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_0.py.snap index 791754ebbf0e6..ad83ffe0ac579 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_0.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_0.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F821_0.py:2:12: F821 Undefined name `self` | @@ -33,10 +32,10 @@ F821_0.py:21:12: F821 Undefined name `numeric_string` F821_0.py:58:5: F821 Undefined name `Bar` | 56 | y: int = 1 -57 | +57 | 58 | x: "Bar" = 1 | ^^^ F821 -59 | +59 | 60 | [first] = ["yup"] | @@ -81,7 +80,7 @@ F821_0.py:93:14: F821 Undefined name `B` 92 | C = f'{A:{B}}' 93 | C = f'{A:{f"{B}"}}' | ^ F821 -94 | +94 | 95 | from typing import Annotated, Literal | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_13.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_13.py.snap index 6ad86a547282b..d156dc3ea9207 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_13.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_13.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F821_13.py:8:19: F821 Undefined name `List` | 6 | Y: ForwardRef("List[int]") -7 | +7 | 8 | Z = TypeVar("X", "List[int]", "int") | ^^^^ F821 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_2.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_2.py.snap index 4c3d9aa3dd182..643cc2a4cb27f 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_2.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_2.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F821_2.py:5:13: F821 Undefined name `Model` | 4 | # F821 Undefined name `Model` 5 | x: Literal["Model"] | ^^^^^ F821 -6 | +6 | 7 | from typing_extensions import Literal | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_20.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_20.py.snap index 1a48677167e51..f791abbfcc668 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_20.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_20.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F821_20.py:3:24: F821 Undefined name `Record` | 1 | """Test lazy evaluation of type alias values.""" -2 | +2 | 3 | type RecordCallback[R: Record] = Callable[[R], None] | ^^^^^^ F821 -4 | +4 | 5 | from collections.abc import Callable | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_28.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_28.py.snap index ff7ec8cad0a36..56103d85adb4a 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_28.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_28.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F821_28.py:9:7: F821 Undefined name `𝒟` | 7 | print(C == 𝑪 == 𝒞 == 𝓒 == 𝕮) -8 | +8 | 9 | print(𝒟) # F821 | ^ F821 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_3.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_3.py.snap index ebe035fe9ea42..2f06a91e4cac5 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_3.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_3.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F821_3.py:11:10: F821 Undefined name `key` | @@ -8,7 +7,7 @@ F821_3.py:11:10: F821 Undefined name `key` 10 | # F821 Undefined name `value` 11 | x: dict["key", "value"] | ^^^ F821 -12 | +12 | 13 | # OK | @@ -18,6 +17,6 @@ F821_3.py:11:17: F821 Undefined name `value` 10 | # F821 Undefined name `value` 11 | x: dict["key", "value"] | ^^^^^ F821 -12 | +12 | 13 | # OK | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_4.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_4.py.snap index de202b8c91adf..9077bbc312e4f 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_4.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_4.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F821_4.py:4:11: F821 Undefined name `Model` | 2 | from typing import List -3 | +3 | 4 | _ = List["Model"] | ^^^^^ F821 | @@ -13,7 +12,7 @@ F821_4.py:4:11: F821 Undefined name `Model` F821_4.py:9:12: F821 Undefined name `Model` | 7 | from typing import List as IList -8 | +8 | 9 | _ = IList["Model"] | ^^^^^ F821 | @@ -21,7 +20,7 @@ F821_4.py:9:12: F821 Undefined name `Model` F821_4.py:14:16: F821 Undefined name `Model` | 12 | from collections.abc import ItemsView -13 | +13 | 14 | _ = ItemsView["Model"] | ^^^^^ F821 | @@ -29,7 +28,7 @@ F821_4.py:14:16: F821 Undefined name `Model` F821_4.py:19:32: F821 Undefined name `Model` | 17 | import collections.abc -18 | +18 | 19 | _ = collections.abc.ItemsView["Model"] | ^^^^^ F821 | @@ -37,7 +36,7 @@ F821_4.py:19:32: F821 Undefined name `Model` F821_4.py:24:20: F821 Undefined name `Model` | 22 | from collections import abc -23 | +23 | 24 | _ = abc.ItemsView["Model"] | ^^^^^ F821 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_0.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_0.py.snap index b0dd404f155dc..10d1e6f4e0145 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_0.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_0.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F822_0.py:3:17: F822 Undefined name `b` in `__all__` | 1 | a = 1 -2 | +2 | 3 | __all__ = ["a", "b"] | ^^^ F822 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_0.pyi.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_0.pyi.snap index cac8528176c72..4810ad460815b 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_0.pyi.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_0.pyi.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F822_0.pyi:4:22: F822 Undefined name `c` in `__all__` | 2 | b: int # Considered a binding in a `.pyi` stub file, not in a `.py` runtime file -3 | +3 | 4 | __all__ = ["a", "b", "c"] # c is flagged as missing; b is not | ^^^ F822 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_1.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_1.py.snap index f74f19c9e9925..5486326ac9707 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_1.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_1.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F822_1.py:3:22: F822 Undefined name `b` in `__all__` | 1 | a = 1 -2 | +2 | 3 | __all__ = list(["a", "b"]) | ^^^ F822 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_1b.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_1b.py.snap index 61789a4154a7f..a52632a6a8593 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_1b.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_1b.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F822_1b.py:4:31: F822 Undefined name `b` in `__all__` | 2 | a = 1 -3 | +3 | 4 | __all__ = builtins.list(["a", "b"]) | ^^^ F822 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F823_F823.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F823_F823.py.snap index ec266a2f4e3b8..75fd12222ab32 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F823_F823.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F823_F823.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F823.py:6:5: F823 Local variable `my_var` referenced before assignment | @@ -31,7 +30,7 @@ F823.py:48:11: F823 Local variable `sys` referenced before assignment 47 | def main(): 48 | print(sys.argv) | ^^^ F823 -49 | +49 | 50 | try: | @@ -40,6 +39,6 @@ F823.py:62:11: F823 Local variable `sys` referenced before assignment 61 | def main(): 62 | print(sys.argv) | ^^^ F823 -63 | +63 | 64 | for sys in range(5): | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_0.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_0.py.snap index b1912dc8373b8..a8a860e83ced6 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_0.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_0.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F841_0.py:3:22: F841 [*] Local variable `e` is assigned to but never used | @@ -64,7 +63,7 @@ F841_0.py:21:6: F841 [*] Local variable `a` is assigned to but never used 20 | foo = (1, 2) 21 | (a, b) = (1, 2) | ^ F841 -22 | +22 | 23 | bar = (1, 2) | = help: Remove assignment to unused variable `a` @@ -85,7 +84,7 @@ F841_0.py:21:9: F841 [*] Local variable `b` is assigned to but never used 20 | foo = (1, 2) 21 | (a, b) = (1, 2) | ^ F841 -22 | +22 | 23 | bar = (1, 2) | = help: Remove assignment to unused variable `b` @@ -103,7 +102,7 @@ F841_0.py:21:9: F841 [*] Local variable `b` is assigned to but never used F841_0.py:26:14: F841 [*] Local variable `baz` is assigned to but never used | 24 | (c, d) = bar -25 | +25 | 26 | (x, y) = baz = bar | ^^^ F841 | @@ -125,7 +124,7 @@ F841_0.py:51:9: F841 [*] Local variable `b` is assigned to but never used 50 | # F841 51 | b = 1 | ^ F841 -52 | +52 | 53 | def d(): | = help: Remove assignment to unused variable `b` @@ -206,7 +205,7 @@ F841_0.py:115:5: F841 [*] Local variable `Baz` is assigned to but never used 114 | Bar = enum.Enum("Bar", "A B") 115 | Baz = enum.Enum("Baz", "A B") | ^^^ F841 -116 | +116 | 117 | match x: | = help: Remove assignment to unused variable `Baz` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_3.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_3.py.snap index b2578711db376..c3250b84513cc 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_3.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_3.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F841_3.py:5:5: F841 [*] Local variable `x` is assigned to but never used | @@ -26,7 +25,7 @@ F841_3.py:6:5: F841 [*] Local variable `y` is assigned to but never used 5 | x = 1 6 | y = 2 | ^ F841 -7 | +7 | 8 | z = 3 | = help: Remove assignment to unused variable `y` @@ -64,7 +63,7 @@ F841_3.py:14:5: F841 [*] Local variable `y` is assigned to but never used 13 | x: int = 1 14 | y: int = 2 | ^ F841 -15 | +15 | 16 | z: int = 3 | = help: Remove assignment to unused variable `y` @@ -100,7 +99,7 @@ F841_3.py:21:19: F841 [*] Local variable `x1` is assigned to but never used F841_3.py:27:20: F841 [*] Local variable `x3` is assigned to but never used | 25 | pass -26 | +26 | 27 | with (foo() as x3, foo() as y3, foo() as z3): | ^^ F841 28 | pass @@ -120,7 +119,7 @@ F841_3.py:27:20: F841 [*] Local variable `x3` is assigned to but never used F841_3.py:27:33: F841 [*] Local variable `y3` is assigned to but never used | 25 | pass -26 | +26 | 27 | with (foo() as x3, foo() as y3, foo() as z3): | ^^ F841 28 | pass @@ -140,7 +139,7 @@ F841_3.py:27:33: F841 [*] Local variable `y3` is assigned to but never used F841_3.py:27:46: F841 [*] Local variable `z3` is assigned to but never used | 25 | pass -26 | +26 | 27 | with (foo() as x3, foo() as y3, foo() as z3): | ^^ F841 28 | pass @@ -299,7 +298,7 @@ F841_3.py:50:5: F841 [*] Local variable `x` is assigned to but never used F841_3.py:56:5: F841 [*] Local variable `y` is assigned to but never used | 54 | ) -55 | +55 | 56 | y = \ | ^ F841 57 | a() if a is not None else b @@ -343,7 +342,7 @@ F841_3.py:61:5: F841 [*] Local variable `x` is assigned to but never used F841_3.py:67:5: F841 [*] Local variable `y` is assigned to but never used | 65 | ) -66 | +66 | 67 | y = \ | ^ F841 68 | a if a is not None else b @@ -666,7 +665,7 @@ F841_3.py:165:5: F841 [*] Local variable `x` is assigned to but never used 164 | def f(): 165 | x = 1 | ^ F841 -166 | +166 | 167 | y = 2 | = help: Remove assignment to unused variable `x` @@ -683,7 +682,7 @@ F841_3.py:165:5: F841 [*] Local variable `x` is assigned to but never used F841_3.py:167:5: F841 [*] Local variable `y` is assigned to but never used | 165 | x = 1 -166 | +166 | 167 | y = 2 | ^ F841 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_global_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_global_scope.snap index fb9a26880665c..9d08e6b818306 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_global_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_global_scope.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- :5:12: F401 [*] `os` imported but unused | 4 | def f(): 5 | import os | ^^ F401 -6 | +6 | 7 | # Despite this `del`, `import os` in `f` should still be flagged as shadowing an unused | = help: Remove unused import: `os` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_local_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_local_scope.snap index 2a0b90409d307..f2a3fb29b29dc 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_local_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_local_scope.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- :2:8: F401 [*] `os` imported but unused | 2 | import os | ^^ F401 -3 | +3 | 4 | def f(): | = help: Remove unused import: `os` @@ -23,7 +22,7 @@ snapshot_kind: text 4 | def f(): 5 | import os | ^^ F811 -6 | +6 | 7 | # Despite this `del`, `import os` in `f` should still be flagged as shadowing an unused | = help: Remove definition: `os` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_import_shadow_in_local_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_import_shadow_in_local_scope.snap index 3fed708c0935d..38f194e1575f7 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_import_shadow_in_local_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_import_shadow_in_local_scope.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- :2:8: F401 [*] `os` imported but unused | 2 | import os | ^^ F401 -3 | +3 | 4 | def f(): | = help: Remove unused import: `os` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_local_import_in_local_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_local_import_in_local_scope.snap index c9f4a87d318d6..2177b874a1916 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_local_import_in_local_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_local_import_in_local_scope.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- :4:12: F811 [*] Redefinition of unused `os` from line 3 | @@ -8,7 +7,7 @@ snapshot_kind: text 3 | import os 4 | import os | ^^ F811 -5 | +5 | 6 | # Despite this `del`, `import os` should still be flagged as shadowing an unused | = help: Remove definition: `os` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f841_dummy_variable_rgx.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f841_dummy_variable_rgx.snap index 169b059e4c30b..c87dbb04b6263 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f841_dummy_variable_rgx.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f841_dummy_variable_rgx.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F841_0.py:3:22: F841 [*] Local variable `e` is assigned to but never used | @@ -45,7 +44,7 @@ F841_0.py:21:6: F841 Local variable `a` is assigned to but never used 20 | foo = (1, 2) 21 | (a, b) = (1, 2) | ^ F841 -22 | +22 | 23 | bar = (1, 2) | = help: Remove assignment to unused variable `a` @@ -56,7 +55,7 @@ F841_0.py:21:9: F841 Local variable `b` is assigned to but never used 20 | foo = (1, 2) 21 | (a, b) = (1, 2) | ^ F841 -22 | +22 | 23 | bar = (1, 2) | = help: Remove assignment to unused variable `b` @@ -64,7 +63,7 @@ F841_0.py:21:9: F841 Local variable `b` is assigned to but never used F841_0.py:26:14: F841 [*] Local variable `baz` is assigned to but never used | 24 | (c, d) = bar -25 | +25 | 26 | (x, y) = baz = bar | ^^^ F841 | @@ -142,7 +141,7 @@ F841_0.py:51:9: F841 [*] Local variable `b` is assigned to but never used 50 | # F841 51 | b = 1 | ^ F841 -52 | +52 | 53 | def d(): | = help: Remove assignment to unused variable `b` @@ -223,7 +222,7 @@ F841_0.py:115:5: F841 [*] Local variable `Baz` is assigned to but never used 114 | Bar = enum.Enum("Bar", "A B") 115 | Baz = enum.Enum("Baz", "A B") | ^^^ F841 -116 | +116 | 117 | match x: | = help: Remove assignment to unused variable `Baz` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__init.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__init.snap index 63a557b09f44d..4153aa879f3c0 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__init.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__init.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- __init__.py:1:8: F401 `os` imported but unused | 1 | import os | ^^ F401 -2 | +2 | 3 | print(__path__) | = help: Remove unused import: `os` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__multi_statement_lines.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__multi_statement_lines.snap index dadea91163d96..2a79871a80fa6 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__multi_statement_lines.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__multi_statement_lines.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- multi_statement_lines.py:2:12: F401 [*] `foo1` imported but unused | @@ -25,7 +24,7 @@ multi_statement_lines.py:3:12: F401 [*] `foo2` imported but unused 2 | import foo1; x = 1 3 | import foo2; x = 1 | ^^^^ F401 -4 | +4 | 5 | if True: | = help: Remove unused import: `foo2` @@ -103,7 +102,7 @@ multi_statement_lines.py:19:17: F401 [*] `foo6` imported but unused 18 | x = 1; \ 19 | import foo6 | ^^^^ F401 -20 | +20 | 21 | if True: | = help: Remove unused import: `foo6` @@ -125,7 +124,7 @@ multi_statement_lines.py:23:18: F401 [*] `foo7` imported but unused 22 | x = 1 \ 23 | ; import foo7 | ^^^^ F401 -24 | +24 | 25 | if True: | = help: Remove unused import: `foo7` @@ -165,7 +164,7 @@ multi_statement_lines.py:27:23: F401 [*] `foo9` imported but unused 26 | x = 1; import foo8; x = 1 27 | x = 1; import foo9; x = 1 | ^^^^ F401 -28 | +28 | 29 | if True: | = help: Remove unused import: `foo9` @@ -226,7 +225,7 @@ multi_statement_lines.py:42:16: F401 [*] `foo12` imported but unused 41 | \ 42 | import foo12 | ^^^^^ F401 -43 | +43 | 44 | if True: | = help: Remove unused import: `foo12` @@ -270,7 +269,7 @@ multi_statement_lines.py:53:12: F401 [*] `foo14` imported but unused 52 | # \ 53 | import foo14 | ^^^^^ F401 -54 | +54 | 55 | # Continuation, but not as the last content in the file. | = help: Remove unused import: `foo14` @@ -290,7 +289,7 @@ multi_statement_lines.py:57:8: F401 [*] `foo15` imported but unused 56 | x = 1; \ 57 | import foo15 | ^^^^^ F401 -58 | +58 | 59 | # Continuation, followed by end-of-file. (Removing `import foo` would cause a syntax | = help: Remove unused import: `foo15` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_29__all_conditional____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_29__all_conditional____init__.py.snap index 324c57b7600c0..57c17bb0c551c 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_29__all_conditional____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_29__all_conditional____init__.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- __init__.py:8:15: F401 `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | 6 | import sys - 7 | + 7 | 8 | from . import unused, exported, renamed as bees | ^^^^^^ F401 - 9 | + 9 | 10 | if sys.version_info > (3, 9): | = help: Remove unused import @@ -16,10 +15,10 @@ __init__.py:8:15: F401 `.unused` imported but unused; consider removing, adding __init__.py:8:44: F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | 6 | import sys - 7 | + 7 | 8 | from . import unused, exported, renamed as bees | ^^^^ F401 - 9 | + 9 | 10 | if sys.version_info > (3, 9): | = help: Remove unused import diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401___init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401___init__.py.snap index fe351ac1582c3..a6ec69a4a586a 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401___init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401___init__.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- __init__.py:1:8: F401 [*] `os` imported but unused | 1 | import os | ^^ F401 -2 | +2 | 3 | print(__path__) | = help: Remove unused import: `os` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F822___init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F822___init__.py.snap index 00bb37925f94d..40b04dfafd39b 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F822___init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F822___init__.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- __init__.py:5:12: F822 Undefined name `a` in `__all__` | 3 | print(__path__) -4 | +4 | 5 | __all__ = ["a", "b", "c"] | ^^^ F822 | @@ -13,7 +12,7 @@ __init__.py:5:12: F822 Undefined name `a` in `__all__` __init__.py:5:17: F822 Undefined name `b` in `__all__` | 3 | print(__path__) -4 | +4 | 5 | __all__ = ["a", "b", "c"] | ^^^ F822 | @@ -21,7 +20,7 @@ __init__.py:5:17: F822 Undefined name `b` in `__all__` __init__.py:5:22: F822 Undefined name `c` in `__all__` | 3 | print(__path__) -4 | +4 | 5 | __all__ = ["a", "b", "c"] | ^^^ F822 | diff --git a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH003_PGH003_0.py.snap b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH003_PGH003_0.py.snap index a1a8c5e22800a..20b023cd3d1ea 100644 --- a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH003_PGH003_0.py.snap +++ b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH003_PGH003_0.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs -snapshot_kind: text --- PGH003_0.py:1:8: PGH003 Use specific rule codes when ignoring type issues | @@ -34,6 +33,6 @@ PGH003_0.py:4:25: PGH003 Use specific rule codes when ignoring type issues 3 | x = 1 # type: ignore[attr-defined] # type: ignore 4 | x = 1 # type: ignoreme # type: ignore | ^^^^^^^^^^^^^^ PGH003 -5 | +5 | 6 | x = 1 | diff --git a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH003_PGH003_1.py.snap b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH003_PGH003_1.py.snap index 71907039153e2..3050506086a0a 100644 --- a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH003_PGH003_1.py.snap +++ b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH003_PGH003_1.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs -snapshot_kind: text --- PGH003_1.py:1:8: PGH003 Use specific rule codes when ignoring type issues | @@ -24,6 +23,6 @@ PGH003_1.py:3:41: PGH003 Use specific rule codes when ignoring type issues 2 | x = 1 # pyright:ignore 3 | x = 1 # pyright: ignore[attr-defined] # pyright: ignore | ^^^^^^^^^^^^^^^^^ PGH003 -4 | +4 | 5 | x = 1 | diff --git a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_0.py.snap b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_0.py.snap index d55e64c88e991..d53e1ef7faed1 100644 --- a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_0.py.snap +++ b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_0.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs -snapshot_kind: text --- PGH004_0.py:1:8: PGH004 Use specific rule codes when using `noqa` | @@ -35,7 +34,7 @@ PGH004_0.py:18:8: PGH004 [*] Use a colon when specifying `noqa` rule codes 17 | # PGH004 18 | x = 2 # noqa X100 | ^^^^^^^ PGH004 -19 | +19 | 20 | # PGH004 | = help: Add missing colon @@ -55,7 +54,7 @@ PGH004_0.py:21:8: PGH004 [*] Use a colon when specifying `noqa` rule codes 20 | # PGH004 21 | x = 2 # noqa X100, X200 | ^^^^^^^ PGH004 -22 | +22 | 23 | # PGH004 | = help: Add missing colon @@ -75,7 +74,7 @@ PGH004_0.py:24:8: PGH004 [*] Do not add spaces between `noqa` and its colon 23 | # PGH004 24 | x = 2 # noqa : X300 | ^^^^^^^ PGH004 -25 | +25 | 26 | # PGH004 | = help: Remove space(s) before colon @@ -95,7 +94,7 @@ PGH004_0.py:27:8: PGH004 [*] Do not add spaces between `noqa` and its colon 26 | # PGH004 27 | x = 2 # noqa : X400 | ^^^^^^^^ PGH004 -28 | +28 | 29 | # PGH004 | = help: Remove space(s) before colon diff --git a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH005_PGH005_0.py.snap b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH005_PGH005_0.py.snap index 076a8fdd9c1a6..1d8c3f41fff02 100644 --- a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH005_PGH005_0.py.snap +++ b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH005_PGH005_0.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs -snapshot_kind: text --- PGH005_0.py:2:8: PGH005 Non-existent mock method: `not_called` | @@ -86,6 +85,6 @@ PGH005_0.py:10:1: PGH005 Mock method should be called: `assert_called_once_with` 9 | my_mock.assert_called_once_with 10 | MyMock.assert_called_once_with | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 -11 | +11 | 12 | # OK | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0105_type_name_incorrect_variance.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0105_type_name_incorrect_variance.py.snap index 149abfc95f5f8..c83f17fe22cb7 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0105_type_name_incorrect_variance.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0105_type_name_incorrect_variance.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- type_name_incorrect_variance.py:5:5: PLC0105 `TypeVar` name "T" does not reflect its covariance; consider renaming it to "T_co" | 3 | # Errors. -4 | +4 | 5 | T = TypeVar("T", covariant=True) | ^^^^^^^ PLC0105 6 | T = TypeVar("T", covariant=True, contravariant=False) @@ -76,14 +75,14 @@ type_name_incorrect_variance.py:12:5: PLC0105 `ParamSpec` name "P" does not refl 11 | P = ParamSpec("P", contravariant=True) 12 | P = ParamSpec("P", covariant=False, contravariant=True) | ^^^^^^^^^ PLC0105 -13 | +13 | 14 | T_co = TypeVar("T_co") | type_name_incorrect_variance.py:14:8: PLC0105 `TypeVar` name "T_co" does not reflect its invariance; consider renaming it to "T" | 12 | P = ParamSpec("P", covariant=False, contravariant=True) -13 | +13 | 14 | T_co = TypeVar("T_co") | ^^^^^^^ PLC0105 15 | T_co = TypeVar("T_co", covariant=False) @@ -194,14 +193,14 @@ type_name_incorrect_variance.py:25:8: PLC0105 `ParamSpec` name "P_co" does not r 24 | P_co = ParamSpec("P_co", contravariant=True) 25 | P_co = ParamSpec("P_co", covariant=False, contravariant=True) | ^^^^^^^^^ PLC0105 -26 | +26 | 27 | T_contra = TypeVar("T_contra") | type_name_incorrect_variance.py:27:12: PLC0105 `TypeVar` name "T_contra" does not reflect its invariance; consider renaming it to "T" | 25 | P_co = ParamSpec("P_co", covariant=False, contravariant=True) -26 | +26 | 27 | T_contra = TypeVar("T_contra") | ^^^^^^^ PLC0105 28 | T_contra = TypeVar("T_contra", covariant=False) @@ -312,6 +311,6 @@ type_name_incorrect_variance.py:38:12: PLC0105 `ParamSpec` name "P_contra" does 37 | P_contra = ParamSpec("P_contra", covariant=True) 38 | P_contra = ParamSpec("P_contra", covariant=True, contravariant=False) | ^^^^^^^^^ PLC0105 -39 | +39 | 40 | # Non-errors. | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0131_type_bivariance.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0131_type_bivariance.py.snap index 7fc2130223cd8..f639f50c42407 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0131_type_bivariance.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0131_type_bivariance.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- type_bivariance.py:5:5: PLC0131 `TypeVar` "T" cannot be both covariant and contravariant | 3 | # Errors. -4 | +4 | 5 | T = TypeVar("T", covariant=True, contravariant=True) | ^^^^^^^ PLC0131 6 | T = TypeVar(name="T", covariant=True, contravariant=True) @@ -16,14 +15,14 @@ type_bivariance.py:6:5: PLC0131 `TypeVar` "T" cannot be both covariant and contr 5 | T = TypeVar("T", covariant=True, contravariant=True) 6 | T = TypeVar(name="T", covariant=True, contravariant=True) | ^^^^^^^ PLC0131 -7 | +7 | 8 | T = ParamSpec("T", covariant=True, contravariant=True) | type_bivariance.py:8:5: PLC0131 `ParamSpec` "T" cannot be both covariant and contravariant | 6 | T = TypeVar(name="T", covariant=True, contravariant=True) -7 | +7 | 8 | T = ParamSpec("T", covariant=True, contravariant=True) | ^^^^^^^^^ PLC0131 9 | T = ParamSpec(name="T", covariant=True, contravariant=True) @@ -34,6 +33,6 @@ type_bivariance.py:9:5: PLC0131 `ParamSpec` "T" cannot be both covariant and con 8 | T = ParamSpec("T", covariant=True, contravariant=True) 9 | T = ParamSpec(name="T", covariant=True, contravariant=True) | ^^^^^^^^^ PLC0131 -10 | +10 | 11 | # Non-errors. | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0132_type_param_name_mismatch.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0132_type_param_name_mismatch.py.snap index 52a93fc53b64f..f2d9025bfeade 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0132_type_param_name_mismatch.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0132_type_param_name_mismatch.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- type_param_name_mismatch.py:5:5: PLC0132 `TypeVar` name `T` does not match assigned variable name `X` | 3 | # Errors. -4 | +4 | 5 | X = TypeVar("T") | ^^^^^^^^^^^^ PLC0132 6 | X = TypeVar(name="T") @@ -16,14 +15,14 @@ type_param_name_mismatch.py:6:5: PLC0132 `TypeVar` name `T` does not match assig 5 | X = TypeVar("T") 6 | X = TypeVar(name="T") | ^^^^^^^^^^^^^^^^^ PLC0132 -7 | +7 | 8 | Y = ParamSpec("T") | type_param_name_mismatch.py:8:5: PLC0132 `ParamSpec` name `T` does not match assigned variable name `Y` | 6 | X = TypeVar(name="T") -7 | +7 | 8 | Y = ParamSpec("T") | ^^^^^^^^^^^^^^ PLC0132 9 | Y = ParamSpec(name="T") @@ -34,14 +33,14 @@ type_param_name_mismatch.py:9:5: PLC0132 `ParamSpec` name `T` does not match ass 8 | Y = ParamSpec("T") 9 | Y = ParamSpec(name="T") | ^^^^^^^^^^^^^^^^^^^ PLC0132 -10 | +10 | 11 | Z = NewType("T", int) | type_param_name_mismatch.py:11:5: PLC0132 `NewType` name `T` does not match assigned variable name `Z` | 9 | Y = ParamSpec(name="T") -10 | +10 | 11 | Z = NewType("T", int) | ^^^^^^^^^^^^^^^^^ PLC0132 12 | Z = NewType(name="T", tp=int) @@ -52,14 +51,14 @@ type_param_name_mismatch.py:12:5: PLC0132 `NewType` name `T` does not match assi 11 | Z = NewType("T", int) 12 | Z = NewType(name="T", tp=int) | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0132 -13 | +13 | 14 | Ws = TypeVarTuple("Ts") | type_param_name_mismatch.py:14:6: PLC0132 `TypeVarTuple` name `Ts` does not match assigned variable name `Ws` | 12 | Z = NewType(name="T", tp=int) -13 | +13 | 14 | Ws = TypeVarTuple("Ts") | ^^^^^^^^^^^^^^^^^^ PLC0132 15 | Ws = TypeVarTuple(name="Ts") @@ -70,6 +69,6 @@ type_param_name_mismatch.py:15:6: PLC0132 `TypeVarTuple` name `Ts` does not matc 14 | Ws = TypeVarTuple("Ts") 15 | Ws = TypeVarTuple(name="Ts") | ^^^^^^^^^^^^^^^^^^^^^^^ PLC0132 -16 | +16 | 17 | # Non-errors. | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0205_single_string_slots.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0205_single_string_slots.py.snap index f37362e3f44d2..eeb9f628e5fa5 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0205_single_string_slots.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0205_single_string_slots.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- single_string_slots.py:3:5: PLC0205 Class `__slots__` should be a non-string iterable | @@ -8,7 +7,7 @@ single_string_slots.py:3:5: PLC0205 Class `__slots__` should be a non-string ite 2 | class Foo: 3 | __slots__ = "bar" | ^^^^^^^^^^^^^^^^^ PLC0205 -4 | +4 | 5 | def __init__(self, bar): | @@ -17,7 +16,7 @@ single_string_slots.py:10:5: PLC0205 Class `__slots__` should be a non-string it 9 | class Foo: 10 | __slots__: str = "bar" | ^^^^^^^^^^^^^^^^^^^^^^ PLC0205 -11 | +11 | 12 | def __init__(self, bar): | @@ -26,6 +25,6 @@ single_string_slots.py:17:5: PLC0205 Class `__slots__` should be a non-string it 16 | class Foo: 17 | __slots__: str = f"bar" | ^^^^^^^^^^^^^^^^^^^^^^^ PLC0205 -18 | +18 | 19 | def __init__(self, bar): | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0206_dict_index_missing_items.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0206_dict_index_missing_items.py.snap index 3efd122617ca8..a2f87d2e5d357 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0206_dict_index_missing_items.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0206_dict_index_missing_items.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- dict_index_missing_items.py:9:1: PLC0206 Extracting value from dictionary without calling `.items()` | @@ -8,61 +7,61 @@ dict_index_missing_items.py:9:1: PLC0206 Extracting value from dictionary withou 9 | / for instrument in ORCHESTRA: 10 | | print(f"{instrument}: {ORCHESTRA[instrument]}") | |___________________________________________________^ PLC0206 -11 | +11 | 12 | for instrument in ORCHESTRA: | dict_index_missing_items.py:12:1: PLC0206 Extracting value from dictionary without calling `.items()` | 10 | print(f"{instrument}: {ORCHESTRA[instrument]}") -11 | +11 | 12 | / for instrument in ORCHESTRA: 13 | | ORCHESTRA[instrument] | |_________________________^ PLC0206 -14 | +14 | 15 | for instrument in ORCHESTRA.keys(): | dict_index_missing_items.py:15:1: PLC0206 Extracting value from dictionary without calling `.items()` | 13 | ORCHESTRA[instrument] -14 | +14 | 15 | / for instrument in ORCHESTRA.keys(): 16 | | print(f"{instrument}: {ORCHESTRA[instrument]}") | |___________________________________________________^ PLC0206 -17 | +17 | 18 | for instrument in ORCHESTRA.keys(): | dict_index_missing_items.py:18:1: PLC0206 Extracting value from dictionary without calling `.items()` | 16 | print(f"{instrument}: {ORCHESTRA[instrument]}") -17 | +17 | 18 | / for instrument in ORCHESTRA.keys(): 19 | | ORCHESTRA[instrument] | |_________________________^ PLC0206 -20 | +20 | 21 | for instrument in (temp_orchestra := {"violin": "strings", "oboe": "woodwind"}): | dict_index_missing_items.py:21:1: PLC0206 Extracting value from dictionary without calling `.items()` | 19 | ORCHESTRA[instrument] -20 | +20 | 21 | / for instrument in (temp_orchestra := {"violin": "strings", "oboe": "woodwind"}): 22 | | print(f"{instrument}: {temp_orchestra[instrument]}") | |________________________________________________________^ PLC0206 -23 | +23 | 24 | for instrument in (temp_orchestra := {"violin": "strings", "oboe": "woodwind"}): | dict_index_missing_items.py:24:1: PLC0206 Extracting value from dictionary without calling `.items()` | 22 | print(f"{instrument}: {temp_orchestra[instrument]}") -23 | +23 | 24 | / for instrument in (temp_orchestra := {"violin": "strings", "oboe": "woodwind"}): 25 | | temp_orchestra[instrument] | |______________________________^ PLC0206 -26 | +26 | 27 | # # OK | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0208_iteration_over_set.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0208_iteration_over_set.py.snap index 435a6a91e56c2..952670e665756 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0208_iteration_over_set.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0208_iteration_over_set.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- iteration_over_set.py:3:13: PLC0208 [*] Use a sequence type instead of a `set` when iterating over values | 1 | # Errors -2 | +2 | 3 | for item in {1}: | ^^^ PLC0208 4 | print(f"I can count to {item}!") @@ -24,7 +23,7 @@ iteration_over_set.py:3:13: PLC0208 [*] Use a sequence type instead of a `set` w iteration_over_set.py:6:13: PLC0208 [*] Use a sequence type instead of a `set` when iterating over values | 4 | print(f"I can count to {item}!") -5 | +5 | 6 | for item in {"apples", "lemons", "water"}: # flags in-line set literals | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0208 7 | print(f"I like {item}.") @@ -44,7 +43,7 @@ iteration_over_set.py:6:13: PLC0208 [*] Use a sequence type instead of a `set` w iteration_over_set.py:9:13: PLC0208 [*] Use a sequence type instead of a `set` when iterating over values | 7 | print(f"I like {item}.") - 8 | + 8 | 9 | for item in {1,}: | ^^^^ PLC0208 10 | print(f"I can count to {item}!") @@ -64,7 +63,7 @@ iteration_over_set.py:9:13: PLC0208 [*] Use a sequence type instead of a `set` w iteration_over_set.py:12:13: PLC0208 [*] Use a sequence type instead of a `set` when iterating over values | 10 | print(f"I can count to {item}!") -11 | +11 | 12 | for item in { | _____________^ 13 | | "apples", "lemons", "water" @@ -90,10 +89,10 @@ iteration_over_set.py:12:13: PLC0208 [*] Use a sequence type instead of a `set` iteration_over_set.py:17:28: PLC0208 [*] Use a sequence type instead of a `set` when iterating over values | 15 | print(f"I like {item}.") -16 | +16 | 17 | numbers_list = [i for i in {1, 2, 3}] # flags sets in list comprehensions | ^^^^^^^^^ PLC0208 -18 | +18 | 19 | numbers_set = {i for i in {1, 2, 3}} # flags sets in set comprehensions | = help: Convert to `tuple` @@ -111,10 +110,10 @@ iteration_over_set.py:17:28: PLC0208 [*] Use a sequence type instead of a `set` iteration_over_set.py:19:27: PLC0208 [*] Use a sequence type instead of a `set` when iterating over values | 17 | numbers_list = [i for i in {1, 2, 3}] # flags sets in list comprehensions -18 | +18 | 19 | numbers_set = {i for i in {1, 2, 3}} # flags sets in set comprehensions | ^^^^^^^^^ PLC0208 -20 | +20 | 21 | numbers_dict = {str(i): i for i in {1, 2, 3}} # flags sets in dict comprehensions | = help: Convert to `tuple` @@ -132,10 +131,10 @@ iteration_over_set.py:19:27: PLC0208 [*] Use a sequence type instead of a `set` iteration_over_set.py:21:36: PLC0208 [*] Use a sequence type instead of a `set` when iterating over values | 19 | numbers_set = {i for i in {1, 2, 3}} # flags sets in set comprehensions -20 | +20 | 21 | numbers_dict = {str(i): i for i in {1, 2, 3}} # flags sets in dict comprehensions | ^^^^^^^^^ PLC0208 -22 | +22 | 23 | numbers_gen = (i for i in {1, 2, 3}) # flags sets in generator expressions | = help: Convert to `tuple` @@ -153,10 +152,10 @@ iteration_over_set.py:21:36: PLC0208 [*] Use a sequence type instead of a `set` iteration_over_set.py:23:27: PLC0208 [*] Use a sequence type instead of a `set` when iterating over values | 21 | numbers_dict = {str(i): i for i in {1, 2, 3}} # flags sets in dict comprehensions -22 | +22 | 23 | numbers_gen = (i for i in {1, 2, 3}) # flags sets in generator expressions | ^^^^^^^^^ PLC0208 -24 | +24 | 25 | # Non-errors | = help: Convert to `tuple` diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0414_import_aliasing.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0414_import_aliasing.py.snap index 034b44cbaec04..483c266aa673a 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0414_import_aliasing.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0414_import_aliasing.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- import_aliasing.py:6:8: PLC0414 [*] Import alias does not rename original package | 4 | # 2. consider-using-from-import -5 | +5 | 6 | import collections as collections # [useless-import-alias] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0414 7 | from collections import OrderedDict as OrderedDict # [useless-import-alias] diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0415_import_outside_top_level.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0415_import_outside_top_level.py.snap index 3e7f1185f7b63..36490ce904468 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0415_import_outside_top_level.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0415_import_outside_top_level.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- import_outside_top_level.py:10:5: PLC0415 `import` should be at the top-level of a file | @@ -63,7 +62,7 @@ import_outside_top_level.py:19:5: PLC0415 `import` should be at the top-level of 18 | class ClassWithImports: 19 | import tokenize # [import-outside-toplevel] | ^^^^^^^^^^^^^^^ PLC0415 -20 | +20 | 21 | def __init__(self): | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC1802_len_as_condition.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC1802_len_as_condition.py.snap index b39fedc66b709..2b64669ae4f89 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC1802_len_as_condition.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC1802_len_as_condition.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- len_as_condition.py:1:4: PLC1802 [*] `len('TEST')` used as condition without comparison | @@ -20,7 +19,7 @@ len_as_condition.py:1:4: PLC1802 [*] `len('TEST')` used as condition without com len_as_condition.py:4:8: PLC1802 [*] `len('TEST')` used as condition without comparison | 2 | pass -3 | +3 | 4 | if not len('TEST'): # [PLC1802] | ^^^^^^^^^^^ PLC1802 5 | pass @@ -59,7 +58,7 @@ len_as_condition.py:8:10: PLC1802 [*] `len(['T', 'E', 'S', 'T'])` used as condit len_as_condition.py:11:12: PLC1802 [*] `len('TEST')` used as condition without comparison | 9 | pass -10 | +10 | 11 | if True or len('TEST'): # [PLC1802] | ^^^^^^^^^^^ PLC1802 12 | pass @@ -119,7 +118,7 @@ len_as_condition.py:58:10: PLC1802 [*] `len('TEST')` used as condition without c len_as_condition.py:61:7: PLC1802 [*] `len('TEST')` used as condition without comparison | 59 | pass -60 | +60 | 61 | while len('TEST'): # [PLC1802] | ^^^^^^^^^^^ PLC1802 62 | pass @@ -139,7 +138,7 @@ len_as_condition.py:61:7: PLC1802 [*] `len('TEST')` used as condition without co len_as_condition.py:64:11: PLC1802 [*] `len('TEST')` used as condition without comparison | 62 | pass -63 | +63 | 64 | while not len('TEST'): # [PLC1802] | ^^^^^^^^^^^ PLC1802 65 | pass @@ -159,7 +158,7 @@ len_as_condition.py:64:11: PLC1802 [*] `len('TEST')` used as condition without c len_as_condition.py:67:13: PLC1802 [*] `len('TEST')` used as condition without comparison | 65 | pass -66 | +66 | 67 | while z and len('TEST'): # [PLC1802] | ^^^^^^^^^^^ PLC1802 68 | pass @@ -179,7 +178,7 @@ len_as_condition.py:67:13: PLC1802 [*] `len('TEST')` used as condition without c len_as_condition.py:70:11: PLC1802 [*] `len('TEST')` used as condition without comparison | 68 | pass -69 | +69 | 70 | while not len('TEST') and z: # [PLC1802] | ^^^^^^^^^^^ PLC1802 71 | pass @@ -201,7 +200,7 @@ len_as_condition.py:93:12: PLC1802 [*] `len(args)` used as condition without com 92 | def github_issue_1331_v2(*args): 93 | assert len(args), args # [PLC1802] | ^^^^^^^^^ PLC1802 -94 | +94 | 95 | def github_issue_1331_v3(*args): | = help: Remove `len` @@ -221,7 +220,7 @@ len_as_condition.py:96:12: PLC1802 [*] `len(args)` used as condition without com 95 | def github_issue_1331_v3(*args): 96 | assert len(args) or z, args # [PLC1802] | ^^^^^^^^^ PLC1802 -97 | +97 | 98 | def github_issue_1331_v4(*args): | = help: Remove `len` @@ -241,7 +240,7 @@ len_as_condition.py:99:18: PLC1802 [*] `len(args)` used as condition without com 98 | def github_issue_1331_v4(*args): 99 | assert z and len(args), args # [PLC1802] | ^^^^^^^^^ PLC1802 -100 | +100 | 101 | def github_issue_1331_v5(**args): | = help: Remove `len` @@ -261,7 +260,7 @@ len_as_condition.py:102:18: PLC1802 [*] `len(args)` used as condition without co 101 | def github_issue_1331_v5(**args): 102 | assert z and len(args), args # [PLC1802] | ^^^^^^^^^ PLC1802 -103 | +103 | 104 | b = bool(len(z)) # [PLC1802] | = help: Remove `len` @@ -279,7 +278,7 @@ len_as_condition.py:102:18: PLC1802 [*] `len(args)` used as condition without co len_as_condition.py:104:10: PLC1802 [*] `len(z)` used as condition without comparison | 102 | assert z and len(args), args # [PLC1802] -103 | +103 | 104 | b = bool(len(z)) # [PLC1802] | ^^^^^^ PLC1802 105 | c = bool(len('TEST') or 42) # [PLC1802] @@ -301,7 +300,7 @@ len_as_condition.py:105:10: PLC1802 [*] `len('TEST')` used as condition without 104 | b = bool(len(z)) # [PLC1802] 105 | c = bool(len('TEST') or 42) # [PLC1802] | ^^^^^^^^^^^ PLC1802 -106 | +106 | 107 | def github_issue_1879(): | = help: Remove `len` diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC1901_compare_to_empty_string.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC1901_compare_to_empty_string.py.snap index 3c06a3e51847c..fefbd85ebcbcd 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC1901_compare_to_empty_string.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC1901_compare_to_empty_string.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- compare_to_empty_string.py:7:13: PLC1901 `x is ""` can be simplified to `not x` as an empty string is falsey | @@ -21,7 +20,7 @@ compare_to_empty_string.py:7:24: PLC1901 `x == ""` can be simplified to `not x` compare_to_empty_string.py:10:17: PLC1901 `y is not ""` can be simplified to `y` as an empty string is falsey | 8 | print("x is an empty string") - 9 | + 9 | 10 | if y is not "" or y != "": | ^^ PLC1901 11 | print("y is not an empty string") @@ -30,7 +29,7 @@ compare_to_empty_string.py:10:17: PLC1901 `y is not ""` can be simplified to `y` compare_to_empty_string.py:10:28: PLC1901 `y != ""` can be simplified to `y` as an empty string is falsey | 8 | print("x is an empty string") - 9 | + 9 | 10 | if y is not "" or y != "": | ^^ PLC1901 11 | print("y is not an empty string") @@ -39,7 +38,7 @@ compare_to_empty_string.py:10:28: PLC1901 `y != ""` can be simplified to `y` as compare_to_empty_string.py:13:8: PLC1901 `"" != z` can be simplified to `z` as an empty string is falsey | 11 | print("y is not an empty string") -12 | +12 | 13 | if "" != z: | ^^ PLC1901 14 | print("z is an empty string") diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2401_non_ascii_name.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2401_non_ascii_name.py.snap index 8608edf5460a3..7cae6936b6b16 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2401_non_ascii_name.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2401_non_ascii_name.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- non_ascii_name.py:1:1: PLC2401 Variable name `ápple_count` contains a non-ASCII character | @@ -26,7 +25,7 @@ non_ascii_name.py:3:1: PLC2401 Variable name `ápple_count` contains a non-ASCII 2 | ápple_count += 2 # C2401 3 | ápple_count = 3 # C2401 | ^^^^^^^^^^^ PLC2401 -4 | +4 | 5 | (ápple_count for ápple_count in y) | = help: Rename the variable using ASCII characters @@ -34,7 +33,7 @@ non_ascii_name.py:3:1: PLC2401 Variable name `ápple_count` contains a non-ASCII non_ascii_name.py:5:18: PLC2401 Variable name `ápple_count` contains a non-ASCII character | 3 | ápple_count = 3 # C2401 -4 | +4 | 5 | (ápple_count for ápple_count in y) | ^^^^^^^^^^^ PLC2401 | @@ -78,10 +77,10 @@ non_ascii_name.py:18:10: PLC2401 Variable name `ápple_count` contains a non-ASC non_ascii_name.py:21:1: PLC2401 Annotation name `ápple_count` contains a non-ASCII character | 19 | pass -20 | +20 | 21 | ápple_count: int | ^^^^^^^^^^^ PLC2401 -22 | +22 | 23 | try: | = help: Rename the variable using ASCII characters diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2403_non_ascii_module_import.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2403_non_ascii_module_import.py.snap index 4d0f38601d1df..c6f20b25ba441 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2403_non_ascii_module_import.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2403_non_ascii_module_import.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- non_ascii_module_import.py:1:29: PLC2403 Module alias `łos` contains a non-ASCII character | @@ -13,7 +12,7 @@ non_ascii_module_import.py:1:29: PLC2403 Module alias `łos` contains a non-ASCI non_ascii_module_import.py:4:24: PLC2403 Module alias `łos` contains a non-ASCII character | 2 | from os.path import join as los # OK -3 | +3 | 4 | import os.path.join as łos # Error | ^^^ PLC2403 5 | import os.path.join as los # OK @@ -23,7 +22,7 @@ non_ascii_module_import.py:4:24: PLC2403 Module alias `łos` contains a non-ASCI non_ascii_module_import.py:7:8: PLC2403 Module name `os.path.łos` contains a non-ASCII character | 5 | import os.path.join as los # OK -6 | +6 | 7 | import os.path.łos # Error (recommend an ASCII alias) | ^^^^^^^^^^^ PLC2403 8 | import os.path.los # OK @@ -33,7 +32,7 @@ non_ascii_module_import.py:7:8: PLC2403 Module name `os.path.łos` contains a no non_ascii_module_import.py:10:21: PLC2403 Module name `łos` contains a non-ASCII character | 8 | import os.path.los # OK - 9 | + 9 | 10 | from os.path import łos # Error (recommend an ASCII alias) | ^^^ PLC2403 11 | from os.path import los # OK diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2701_import_private_name__submodule____main__.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2701_import_private_name__submodule____main__.py.snap index 6c049c0b72588..2946c74128c5d 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2701_import_private_name__submodule____main__.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2701_import_private_name__submodule____main__.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- __main__.py:2:16: PLC2701 Private name import `_a` | @@ -66,6 +65,6 @@ __main__.py:8:24: PLC2701 Private name import `_ddd` from external module `bbb.c 7 | import _aaa 8 | import bbb.ccc._ddd as eee # Panicked in https://github.com/astral-sh/ruff/pull/5920 | ^^^ PLC2701 - 9 | + 9 | 10 | # Non-errors. | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2801_unnecessary_dunder_call.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2801_unnecessary_dunder_call.py.snap index bc41c2974d8a4..e3ba6a0048eeb 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2801_unnecessary_dunder_call.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2801_unnecessary_dunder_call.py.snap @@ -729,7 +729,7 @@ unnecessary_dunder_call.py:46:6: PLC2801 [*] Unnecessary dunder call to `__add__ 45 | x = (-a).__add__(3) # PLC2801 46 | x = -(-a).__add__(3) # PLC2801 | ^^^^^^^^^^^^^^^ PLC2801 -47 | +47 | 48 | # Calls | = help: Use `+` operator @@ -749,7 +749,7 @@ unnecessary_dunder_call.py:49:7: PLC2801 Unnecessary dunder call to `__call__` 48 | # Calls 49 | print(a.__call__()) # PLC2801 (no fix, intentional) | ^^^^^^^^^^^^ PLC2801 -50 | +50 | 51 | # Lambda expressions | @@ -758,7 +758,7 @@ unnecessary_dunder_call.py:52:16: PLC2801 [*] Unnecessary dunder call to `__add_ 51 | # Lambda expressions 52 | blah = lambda: a.__add__(1) # PLC2801 | ^^^^^^^^^^^^ PLC2801 -53 | +53 | 54 | # If expressions | = help: Use `+` operator @@ -778,7 +778,7 @@ unnecessary_dunder_call.py:55:7: PLC2801 [*] Unnecessary dunder call to `__add__ 54 | # If expressions 55 | print(a.__add__(1) if a > 0 else a.__sub__(1)) # PLC2801 | ^^^^^^^^^^^^ PLC2801 -56 | +56 | 57 | # Dict/Set/List/Tuple | = help: Use `+` operator @@ -798,7 +798,7 @@ unnecessary_dunder_call.py:55:34: PLC2801 [*] Unnecessary dunder call to `__sub_ 54 | # If expressions 55 | print(a.__add__(1) if a > 0 else a.__sub__(1)) # PLC2801 | ^^^^^^^^^^^^ PLC2801 -56 | +56 | 57 | # Dict/Set/List/Tuple | = help: Use `-` operator @@ -880,7 +880,7 @@ unnecessary_dunder_call.py:61:8: PLC2801 [*] Unnecessary dunder call to `__add__ 60 | print([a.__add__(1)]) # PLC2801 61 | print((a.__add__(1),)) # PLC2801 | ^^^^^^^^^^^^ PLC2801 -62 | +62 | 63 | # Comprehension variants | = help: Use `+` operator @@ -962,7 +962,7 @@ unnecessary_dunder_call.py:67:8: PLC2801 [*] Unnecessary dunder call to `__add__ 66 | print([i.__add__(1) for i in range(5)]) # PLC2801 67 | print((i.__add__(1) for i in range(5))) # PLC2801 | ^^^^^^^^^^^^ PLC2801 -68 | +68 | 69 | # Generators | = help: Use `+` operator @@ -1001,7 +1001,7 @@ unnecessary_dunder_call.py:74:13: PLC2801 [*] Unnecessary dunder call to `__add_ 73 | # Subscripts 74 | print({"a": a.__add__(1)}["a"]) # PLC2801 | ^^^^^^^^^^^^ PLC2801 -75 | +75 | 76 | # Starred | = help: Use `+` operator @@ -1021,7 +1021,7 @@ unnecessary_dunder_call.py:77:9: PLC2801 [*] Unnecessary dunder call to `__add__ 76 | # Starred 77 | print(*[a.__add__(1)]) # PLC2801 | ^^^^^^^^^^^^ PLC2801 -78 | +78 | 79 | # Slices | = help: Use `+` operator @@ -1077,7 +1077,7 @@ unnecessary_dunder_call.py:92:16: PLC2801 Unnecessary dunder call to `__getattri 91 | def do_thing(self, item): 92 | return object.__getattribute__(self, item) # PLC2801 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC2801 -93 | +93 | 94 | def use_descriptor(self, item): | = help: Access attribute directly or use getattr built-in function @@ -1085,10 +1085,10 @@ unnecessary_dunder_call.py:92:16: PLC2801 Unnecessary dunder call to `__getattri unnecessary_dunder_call.py:104:1: PLC2801 [*] Unnecessary dunder call to `__contains__`. Use `in` operator. | 102 | blah = dict[{"a": 1}.__delitem__("a")] # OK -103 | +103 | 104 | "abc".__contains__("a") | ^^^^^^^^^^^^^^^^^^^^^^^ PLC2801 -105 | +105 | 106 | # https://github.com/astral-sh/ruff/issues/14597 | = help: Use `in` operator diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC3002_unnecessary_direct_lambda_call.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC3002_unnecessary_direct_lambda_call.py.snap index f88db1463f121..d80235c4b6432 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC3002_unnecessary_direct_lambda_call.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC3002_unnecessary_direct_lambda_call.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- unnecessary_direct_lambda_call.py:4:5: PLC3002 Lambda expression called directly. Execute the expression inline instead. | 2 | # pylint: disable=undefined-variable, line-too-long -3 | +3 | 4 | y = (lambda x: x**2 + 2*x + 1)(a) # [unnecessary-direct-lambda-call] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC3002 5 | y = max((lambda x: x**2)(a), (lambda x: x+1)(a)) # [unnecessary-direct-lambda-call,unnecessary-direct-lambda-call] diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0100_yield_in_init.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0100_yield_in_init.py.snap index f48dbd4ef58c3..7fefeeb11b8e6 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0100_yield_in_init.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0100_yield_in_init.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- yield_in_init.py:9:9: PLE0100 `__init__` method is a generator | @@ -16,6 +15,6 @@ yield_in_init.py:14:9: PLE0100 `__init__` method is a generator 13 | def __init__(self): 14 | yield from self.gen() | ^^^^^^^^^^^^^^^^^^^^^ PLE0100 -15 | +15 | 16 | def gen(self): | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0101_return_in_init.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0101_return_in_init.py.snap index fb0d2c41c9f8e..79ae8f1ae639e 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0101_return_in_init.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0101_return_in_init.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- return_in_init.py:14:9: PLE0101 Explicit return in `__init__` | @@ -8,7 +7,7 @@ return_in_init.py:14:9: PLE0101 Explicit return in `__init__` 13 | def __init__(self): 14 | return 3 | ^^^^^^^^ PLE0101 -15 | +15 | 16 | def gen(self): | @@ -17,6 +16,6 @@ return_in_init.py:22:9: PLE0101 Explicit return in `__init__` 21 | def __init__(self): 22 | return 1 | ^^^^^^^^ PLE0101 -23 | +23 | 24 | class MyClass2: | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0118_load_before_global_declaration.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0118_load_before_global_declaration.py.snap index 0327dcd015281..5d1994780df2a 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0118_load_before_global_declaration.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0118_load_before_global_declaration.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- load_before_global_declaration.py:5:11: PLE0118 Name `x` is used prior to global declaration on line 7 | @@ -8,17 +7,17 @@ load_before_global_declaration.py:5:11: PLE0118 Name `x` is used prior to global 4 | def f(): 5 | print(x) | ^ PLE0118 -6 | +6 | 7 | global x | load_before_global_declaration.py:15:11: PLE0118 Name `x` is used prior to global declaration on line 17 | 13 | global x -14 | +14 | 15 | print(x) | ^ PLE0118 -16 | +16 | 17 | global x | @@ -27,17 +26,17 @@ load_before_global_declaration.py:23:11: PLE0118 Name `x` is used prior to globa 22 | def f(): 23 | print(x) | ^ PLE0118 -24 | +24 | 25 | global x, y | load_before_global_declaration.py:33:11: PLE0118 Name `x` is used prior to global declaration on line 35 | 31 | global x, y -32 | +32 | 33 | print(x) | ^ PLE0118 -34 | +34 | 35 | global x, y | @@ -46,17 +45,17 @@ load_before_global_declaration.py:41:5: PLE0118 Name `x` is used prior to global 40 | def f(): 41 | x = 1 | ^ PLE0118 -42 | +42 | 43 | global x | load_before_global_declaration.py:51:5: PLE0118 Name `x` is used prior to global declaration on line 53 | 49 | global x -50 | +50 | 51 | x = 1 | ^ PLE0118 -52 | +52 | 53 | global x | @@ -65,17 +64,17 @@ load_before_global_declaration.py:59:9: PLE0118 Name `x` is used prior to global 58 | def f(): 59 | del x | ^ PLE0118 -60 | +60 | 61 | global x, y | load_before_global_declaration.py:69:9: PLE0118 Name `x` is used prior to global declaration on line 71 | 67 | global x, y -68 | +68 | 69 | del x | ^ PLE0118 -70 | +70 | 71 | global x, y | @@ -84,17 +83,17 @@ load_before_global_declaration.py:77:9: PLE0118 Name `x` is used prior to global 76 | def f(): 77 | del x | ^ PLE0118 -78 | +78 | 79 | global x | load_before_global_declaration.py:87:9: PLE0118 Name `x` is used prior to global declaration on line 89 | 85 | global x -86 | +86 | 87 | del x | ^ PLE0118 -88 | +88 | 89 | global x | @@ -103,17 +102,17 @@ load_before_global_declaration.py:95:9: PLE0118 Name `x` is used prior to global 94 | def f(): 95 | del x | ^ PLE0118 -96 | +96 | 97 | global x, y | load_before_global_declaration.py:105:9: PLE0118 Name `x` is used prior to global declaration on line 107 | 103 | global x, y -104 | +104 | 105 | del x | ^ PLE0118 -106 | +106 | 107 | global x, y | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0302_unexpected_special_method_signature.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0302_unexpected_special_method_signature.py.snap index 986b0c52d560d..41db89bed422f 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0302_unexpected_special_method_signature.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0302_unexpected_special_method_signature.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- unexpected_special_method_signature.py:5:9: PLE0302 The special method `__bool__` expects 1 parameter, 2 were given | 3 | ... -4 | +4 | 5 | def __bool__(self, x): # too many mandatory args | ^^^^^^^^ PLE0302 6 | ... @@ -22,7 +21,7 @@ unexpected_special_method_signature.py:19:9: PLE0302 The special method `__bool_ unexpected_special_method_signature.py:32:9: PLE0302 The special method `__eq__` expects 2 parameters, 1 was given | 30 | ... -31 | +31 | 32 | def __eq__(self): # too few mandatory args | ^^^^^^ PLE0302 33 | ... @@ -31,7 +30,7 @@ unexpected_special_method_signature.py:32:9: PLE0302 The special method `__eq__` unexpected_special_method_signature.py:35:9: PLE0302 The special method `__eq__` expects 2 parameters, 3 were given | 33 | ... -34 | +34 | 35 | def __eq__(self, other, other_other): # too many mandatory args | ^^^^^^ PLE0302 36 | ... @@ -40,7 +39,7 @@ unexpected_special_method_signature.py:35:9: PLE0302 The special method `__eq__` unexpected_special_method_signature.py:44:9: PLE0302 The special method `__round__` expects between 1 and 2 parameters, 3 were given | 42 | ... -43 | +43 | 44 | def __round__(self, x, y): # disallow 2 args | ^^^^^^^^^ PLE0302 45 | ... @@ -49,7 +48,7 @@ unexpected_special_method_signature.py:44:9: PLE0302 The special method `__round unexpected_special_method_signature.py:47:9: PLE0302 The special method `__round__` expects between 1 and 2 parameters, 4 were given | 45 | ... -46 | +46 | 47 | def __round__(self, x, y, z=2): # disallow 3 args even when one is optional | ^^^^^^^^^ PLE0302 48 | ... @@ -58,7 +57,7 @@ unexpected_special_method_signature.py:47:9: PLE0302 The special method `__round unexpected_special_method_signature.py:56:9: PLE0302 The special method `__eq__` expects 2 parameters, 3 were given | 54 | ... -55 | +55 | 56 | def __eq__(self, x, y, *args): # too many args with *args | ^^^^^^ PLE0302 57 | ... @@ -67,7 +66,7 @@ unexpected_special_method_signature.py:56:9: PLE0302 The special method `__eq__` unexpected_special_method_signature.py:65:9: PLE0302 The special method `__round__` expects between 1 and 2 parameters, 3 were given | 63 | ... -64 | +64 | 65 | def __round__(self, x, y, *args): # disallow 2 args | ^^^^^^^^^ PLE0302 66 | ... diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0304_invalid_return_type_bool.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0304_invalid_return_type_bool.py.snap index 46c5c0b1b3310..4f156b0611503 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0304_invalid_return_type_bool.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0304_invalid_return_type_bool.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- invalid_return_type_bool.py:5:16: PLE0304 `__bool__` does not return `bool` | @@ -8,7 +7,7 @@ invalid_return_type_bool.py:5:16: PLE0304 `__bool__` does not return `bool` 4 | def __bool__(self): 5 | return 3.05 # [invalid-bool-return] | ^^^^ PLE0304 -6 | +6 | 7 | class Int: | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0604_invalid_all_object.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0604_invalid_all_object.py.snap index f005580eac6d9..775afaf683ffe 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0604_invalid_all_object.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0604_invalid_all_object.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- invalid_all_object.py:1:1: PLE0604 Invalid object in `__all__`, must contain only strings | @@ -13,7 +12,7 @@ invalid_all_object.py:1:1: PLE0604 Invalid object in `__all__`, must contain onl invalid_all_object.py:7:1: PLE0604 Invalid object in `__all__`, must contain only strings | 5 | ) -6 | +6 | 7 | __all__ = list([None, "Fruit", "Worm"]) # [invalid-all-object] | ^^^^^^^ PLE0604 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0605_invalid_all_format.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0605_invalid_all_format.py.snap index 37bcd9349a7c2..f2ae393351f2d 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0605_invalid_all_format.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0605_invalid_all_format.py.snap @@ -1,131 +1,130 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- invalid_all_format.py:1:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` | 1 | __all__ = "CONST" # [invalid-all-format] | ^^^^^^^ PLE0605 -2 | +2 | 3 | __all__ = ["Hello"] + {"world"} # [invalid-all-format] | invalid_all_format.py:3:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` | 1 | __all__ = "CONST" # [invalid-all-format] -2 | +2 | 3 | __all__ = ["Hello"] + {"world"} # [invalid-all-format] | ^^^^^^^ PLE0605 -4 | +4 | 5 | __all__ += {"world"} # [invalid-all-format] | invalid_all_format.py:5:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` | 3 | __all__ = ["Hello"] + {"world"} # [invalid-all-format] -4 | +4 | 5 | __all__ += {"world"} # [invalid-all-format] | ^^^^^^^ PLE0605 -6 | +6 | 7 | __all__ = {"world"} + ["Hello"] # [invalid-all-format] | invalid_all_format.py:7:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` | 5 | __all__ += {"world"} # [invalid-all-format] -6 | +6 | 7 | __all__ = {"world"} + ["Hello"] # [invalid-all-format] | ^^^^^^^ PLE0605 -8 | +8 | 9 | __all__ = {"world"} + list(["Hello"]) # [invalid-all-format] | invalid_all_format.py:9:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` | 7 | __all__ = {"world"} + ["Hello"] # [invalid-all-format] - 8 | + 8 | 9 | __all__ = {"world"} + list(["Hello"]) # [invalid-all-format] | ^^^^^^^ PLE0605 -10 | +10 | 11 | __all__ = list(["Hello"]) + {"world"} # [invalid-all-format] | invalid_all_format.py:11:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` | 9 | __all__ = {"world"} + list(["Hello"]) # [invalid-all-format] -10 | +10 | 11 | __all__ = list(["Hello"]) + {"world"} # [invalid-all-format] | ^^^^^^^ PLE0605 -12 | +12 | 13 | __all__ = (x for x in ["Hello", "world"]) # [invalid-all-format] | invalid_all_format.py:13:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` | 11 | __all__ = list(["Hello"]) + {"world"} # [invalid-all-format] -12 | +12 | 13 | __all__ = (x for x in ["Hello", "world"]) # [invalid-all-format] | ^^^^^^^ PLE0605 -14 | +14 | 15 | __all__ = {x for x in ["Hello", "world"]} # [invalid-all-format] | invalid_all_format.py:15:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` | 13 | __all__ = (x for x in ["Hello", "world"]) # [invalid-all-format] -14 | +14 | 15 | __all__ = {x for x in ["Hello", "world"]} # [invalid-all-format] | ^^^^^^^ PLE0605 -16 | +16 | 17 | __all__ = foo # [invalid-all-format] | invalid_all_format.py:17:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` | 15 | __all__ = {x for x in ["Hello", "world"]} # [invalid-all-format] -16 | +16 | 17 | __all__ = foo # [invalid-all-format] | ^^^^^^^ PLE0605 -18 | +18 | 19 | __all__ = foo.bar # [invalid-all-format] | invalid_all_format.py:19:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` | 17 | __all__ = foo # [invalid-all-format] -18 | +18 | 19 | __all__ = foo.bar # [invalid-all-format] | ^^^^^^^ PLE0605 -20 | +20 | 21 | __all__ = foo["bar"] # [invalid-all-format] | invalid_all_format.py:21:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` | 19 | __all__ = foo.bar # [invalid-all-format] -20 | +20 | 21 | __all__ = foo["bar"] # [invalid-all-format] | ^^^^^^^ PLE0605 -22 | +22 | 23 | __all__ = (foo := bar) # [invalid-all-format] | invalid_all_format.py:23:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` | 21 | __all__ = foo["bar"] # [invalid-all-format] -22 | +22 | 23 | __all__ = (foo := bar) # [invalid-all-format] | ^^^^^^^ PLE0605 -24 | +24 | 25 | __all__ = ["Hello"] | invalid_all_format.py:23:12: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` | 21 | __all__ = foo["bar"] # [invalid-all-format] -22 | +22 | 23 | __all__ = (foo := bar) # [invalid-all-format] | ^^^ PLE0605 -24 | +24 | 25 | __all__ = ["Hello"] | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0643_potential_index_error.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0643_potential_index_error.py.snap index 5297c23240324..78dcba4f7737f 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0643_potential_index_error.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0643_potential_index_error.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- potential_index_error.py:1:17: PLE0643 Expression is likely to raise `IndexError` | @@ -34,6 +33,6 @@ potential_index_error.py:4:17: PLE0643 Expression is likely to raise `IndexError 3 | print([1, 2, 3][999999999999999999999999999999999999999999]) # PLE0643 4 | print([1, 2, 3][-999999999999999999999999999999999999999999]) # PLE0643 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE0643 -5 | +5 | 6 | print([1, 2, 3][2]) # OK | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0704_misplaced_bare_raise.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0704_misplaced_bare_raise.py.snap index 3ea614ed296c2..560e9029f0e60 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0704_misplaced_bare_raise.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0704_misplaced_bare_raise.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- misplaced_bare_raise.py:30:5: PLE0704 Bare `raise` statement is not inside an exception handler | @@ -26,7 +25,7 @@ misplaced_bare_raise.py:41:5: PLE0704 Bare `raise` statement is not inside an ex 40 | def g(): 41 | raise # [misplaced-bare-raise] | ^^^^^ PLE0704 -42 | +42 | 43 | def h(): | @@ -46,17 +45,17 @@ misplaced_bare_raise.py:50:5: PLE0704 Bare `raise` statement is not inside an ex 49 | pass 50 | raise # [misplaced-bare-raise] | ^^^^^ PLE0704 -51 | +51 | 52 | raise # [misplaced-bare-raise] | misplaced_bare_raise.py:52:1: PLE0704 Bare `raise` statement is not inside an exception handler | 50 | raise # [misplaced-bare-raise] -51 | +51 | 52 | raise # [misplaced-bare-raise] | ^^^^^ PLE0704 -53 | +53 | 54 | try: | @@ -66,7 +65,7 @@ misplaced_bare_raise.py:58:9: PLE0704 Bare `raise` statement is not inside an ex 57 | def i(): 58 | raise # [misplaced-bare-raise] | ^^^^^ PLE0704 -59 | +59 | 60 | try: | @@ -76,7 +75,7 @@ misplaced_bare_raise.py:64:9: PLE0704 Bare `raise` statement is not inside an ex 63 | class C: 64 | raise # [misplaced-bare-raise] | ^^^^^ PLE0704 -65 | +65 | 66 | try: | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1141_dict_iter_missing_items.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1141_dict_iter_missing_items.py.snap index 18a4ebb0787fe..c99492114a6bf 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1141_dict_iter_missing_items.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1141_dict_iter_missing_items.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- dict_iter_missing_items.py:13:13: PLE1141 [*] Unpacking a dictionary in iteration without calling `.items()` | @@ -24,7 +23,7 @@ dict_iter_missing_items.py:13:13: PLE1141 [*] Unpacking a dictionary in iteratio dict_iter_missing_items.py:16:13: PLE1141 [*] Unpacking a dictionary in iteration without calling `.items()` | 14 | pass -15 | +15 | 16 | for k, v in d_tuple_incorrect_tuple: | ^^^^^^^^^^^^^^^^^^^^^^^ PLE1141 17 | pass diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1205_logging_too_many_args.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1205_logging_too_many_args.py.snap index 8e9100b14a043..d905356f3dc09 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1205_logging_too_many_args.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1205_logging_too_many_args.py.snap @@ -1,43 +1,42 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- logging_too_many_args.py:3:1: PLE1205 Too many arguments for `logging` format string | 1 | import logging -2 | +2 | 3 | logging.warning("Hello %s", "World!", "again") # [logging-too-many-args] | ^^^^^^^^^^^^^^^ PLE1205 -4 | +4 | 5 | logging.warning("Hello %s", "World!", "again", something="else") | logging_too_many_args.py:5:1: PLE1205 Too many arguments for `logging` format string | 3 | logging.warning("Hello %s", "World!", "again") # [logging-too-many-args] -4 | +4 | 5 | logging.warning("Hello %s", "World!", "again", something="else") | ^^^^^^^^^^^^^^^ PLE1205 -6 | +6 | 7 | logging.warning("Hello %s", "World!") | logging_too_many_args.py:29:1: PLE1205 Too many arguments for `logging` format string | 27 | from logging import info, error, warning -28 | +28 | 29 | warning("Hello %s", "World!", "again") # [logging-too-many-args] | ^^^^^^^ PLE1205 -30 | +30 | 31 | warning("Hello %s", "World!", "again", something="else") | logging_too_many_args.py:31:1: PLE1205 Too many arguments for `logging` format string | 29 | warning("Hello %s", "World!", "again") # [logging-too-many-args] -30 | +30 | 31 | warning("Hello %s", "World!", "again", something="else") | ^^^^^^^ PLE1205 -32 | +32 | 33 | warning("Hello %s", "World!") | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1206_logging_too_few_args.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1206_logging_too_few_args.py.snap index fc1a75b237f6f..0961e1b05ff2d 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1206_logging_too_few_args.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1206_logging_too_few_args.py.snap @@ -1,23 +1,22 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- logging_too_few_args.py:3:1: PLE1206 Not enough arguments for `logging` format string | 1 | import logging -2 | +2 | 3 | logging.warning("Hello %s %s", "World!") # [logging-too-few-args] | ^^^^^^^^^^^^^^^ PLE1206 -4 | +4 | 5 | # do not handle calls with kwargs (like pylint) | logging_too_few_args.py:33:1: PLE1206 Not enough arguments for `logging` format string | 31 | from logging import error, info, warning -32 | +32 | 33 | warning("Hello %s %s", "World!") # [logging-too-few-args] | ^^^^^^^ PLE1206 -34 | +34 | 35 | # do not handle calls with kwargs (like pylint) | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1300_bad_string_format_character.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1300_bad_string_format_character.py.snap index 8d0af5bba7ce9..aed97848eeab8 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1300_bad_string_format_character.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1300_bad_string_format_character.py.snap @@ -1,54 +1,53 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- bad_string_format_character.py:5:1: PLE1300 Unsupported format character 'z' | 3 | ## Old style formatting -4 | +4 | 5 | "%s %z" % ("hello", "world") # [bad-format-character] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 -6 | +6 | 7 | "%s" "%z" % ("hello", "world") # [bad-format-character] | bad_string_format_character.py:7:1: PLE1300 Unsupported format character 'z' | 5 | "%s %z" % ("hello", "world") # [bad-format-character] -6 | +6 | 7 | "%s" "%z" % ("hello", "world") # [bad-format-character] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 -8 | +8 | 9 | """%s %z""" % ("hello", "world") # [bad-format-character] | bad_string_format_character.py:9:1: PLE1300 Unsupported format character 'z' | 7 | "%s" "%z" % ("hello", "world") # [bad-format-character] - 8 | + 8 | 9 | """%s %z""" % ("hello", "world") # [bad-format-character] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 -10 | +10 | 11 | """%s""" """%z""" % ("hello", "world") # [bad-format-character] | bad_string_format_character.py:11:1: PLE1300 Unsupported format character 'z' | 9 | """%s %z""" % ("hello", "world") # [bad-format-character] -10 | +10 | 11 | """%s""" """%z""" % ("hello", "world") # [bad-format-character] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 -12 | +12 | 13 | ## New style formatting | bad_string_format_character.py:15:1: PLE1300 Unsupported format character 'y' | 13 | ## New style formatting -14 | +14 | 15 | "{:s} {:y}".format("hello", "world") # [bad-format-character] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 -16 | +16 | 17 | "{:*^30s}".format("centered") # OK | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1307_bad_string_format_type.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1307_bad_string_format_type.py.snap index 2adea4bd7bdaf..971f3addb6b40 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1307_bad_string_format_type.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1307_bad_string_format_type.py.snap @@ -1,30 +1,29 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- bad_string_format_type.py:2:7: PLE1307 Format type does not match argument type | 1 | # Errors 2 | print("foo %(foo)d bar %(bar)d" % {"foo": "1", "bar": "2"}) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 -3 | +3 | 4 | "foo %e bar %s" % ("1", 2) | bad_string_format_type.py:4:1: PLE1307 Format type does not match argument type | 2 | print("foo %(foo)d bar %(bar)d" % {"foo": "1", "bar": "2"}) -3 | +3 | 4 | "foo %e bar %s" % ("1", 2) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 -5 | +5 | 6 | "%d" % "1" | bad_string_format_type.py:6:1: PLE1307 Format type does not match argument type | 4 | "foo %e bar %s" % ("1", 2) -5 | +5 | 6 | "%d" % "1" | ^^^^^^^^^^ PLE1307 7 | "%o" % "1" @@ -125,6 +124,6 @@ bad_string_format_type.py:16:1: PLE1307 Format type does not match argument type 15 | "%d" % ((1, 2, 3),) 16 | "%d" % (1 if x > 0 else []) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 -17 | +17 | 18 | # False negatives | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1507_invalid_envvar_value.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1507_invalid_envvar_value.py.snap index 3aa744425cb0d..79e29de638f50 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1507_invalid_envvar_value.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1507_invalid_envvar_value.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- invalid_envvar_value.py:3:11: PLE1507 Invalid type for initial `os.getenv` argument; expected `str` | 1 | import os -2 | +2 | 3 | os.getenv(1) # [invalid-envvar-value] | ^ PLE1507 4 | os.getenv("a") @@ -48,6 +47,6 @@ invalid_envvar_value.py:14:11: PLE1507 Invalid type for initial `os.getenv` argu 13 | os.getenv("PATH_TEST" if using_clear_path else "PATH_ORIG") 14 | os.getenv(1 if using_clear_path else "PATH_ORIG") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1507 -15 | +15 | 16 | AA = "aa" | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1519_singledispatch_method.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1519_singledispatch_method.py.snap index 1f04b66ce6ccc..4ec3382c4b1cd 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1519_singledispatch_method.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1519_singledispatch_method.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- singledispatch_method.py:10:5: PLE1519 [*] `@singledispatch` decorator should not be used on methods | @@ -25,7 +24,7 @@ singledispatch_method.py:10:5: PLE1519 [*] `@singledispatch` decorator should no singledispatch_method.py:15:5: PLE1519 [*] `@singledispatch` decorator should not be used on methods | 13 | pass -14 | +14 | 15 | @singledispatch # [singledispatch-method] | ^^^^^^^^^^^^^^^ PLE1519 16 | def move(self, position): @@ -46,7 +45,7 @@ singledispatch_method.py:15:5: PLE1519 [*] `@singledispatch` decorator should no singledispatch_method.py:23:5: PLE1519 [*] `@singledispatch` decorator should not be used on methods | 21 | pass -22 | +22 | 23 | @singledispatch # [singledispatch-method] | ^^^^^^^^^^^^^^^ PLE1519 24 | @staticmethod diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2510_invalid_characters.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2510_invalid_characters.py.snap index dea10050924b2..b6f94b3dbf93f 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2510_invalid_characters.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2510_invalid_characters.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- invalid_characters.py:15:6: PLE2510 [*] Invalid unescaped character backspace, use "\b" instead | @@ -28,7 +27,7 @@ invalid_characters.py:16:7: PLE2510 [*] Invalid unescaped character backspace, u 15 | b = '␈' 16 | b = f'␈' | ^ PLE2510 -17 | +17 | 18 | b_ok = '\\b' | = help: Replace with escape sequence @@ -46,10 +45,10 @@ invalid_characters.py:16:7: PLE2510 [*] Invalid unescaped character backspace, u invalid_characters.py:55:21: PLE2510 [*] Invalid unescaped character backspace, use "\b" instead | 53 | zwsp_after_multicharacter_grapheme_cluster = f"ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" -54 | +54 | 55 | nested_fstrings = f'␈{f'{f'␛'}'}' | ^ PLE2510 -56 | +56 | 57 | # https://github.com/astral-sh/ruff/issues/7455#issuecomment-1741998106 | = help: Replace with escape sequence diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2513_invalid_characters.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2513_invalid_characters.py.snap index dc7aaba7f02d9..72e7b93e0765f 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2513_invalid_characters.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2513_invalid_characters.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- invalid_characters.py:30:16: PLE2513 [*] Invalid unescaped character ESC, use "\x1B" instead | 28 | sub_ok = f'\x1a' -29 | +29 | 30 | esc = 'esc esc ␛' | ^ PLE2513 31 | esc = f'esc esc ␛' @@ -27,7 +26,7 @@ invalid_characters.py:31:17: PLE2513 [*] Invalid unescaped character ESC, use "\ 30 | esc = 'esc esc ␛' 31 | esc = f'esc esc ␛' | ^ PLE2513 -32 | +32 | 33 | esc_ok = '\x1b' | = help: Replace with escape sequence @@ -45,10 +44,10 @@ invalid_characters.py:31:17: PLE2513 [*] Invalid unescaped character ESC, use "\ invalid_characters.py:55:29: PLE2513 [*] Invalid unescaped character ESC, use "\x1B" instead | 53 | zwsp_after_multicharacter_grapheme_cluster = f"ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" -54 | +54 | 55 | nested_fstrings = f'␈{f'{f'␛'}'}' | ^ PLE2513 -56 | +56 | 57 | # https://github.com/astral-sh/ruff/issues/7455#issuecomment-1741998106 | = help: Replace with escape sequence diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE4703_modified_iterating_set.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE4703_modified_iterating_set.py.snap index a3d8ed567b11c..d7d35b39f0657 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE4703_modified_iterating_set.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE4703_modified_iterating_set.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- modified_iterating_set.py:4:1: PLE4703 [*] Iterated set `nums` is modified within the `for` loop | @@ -8,7 +7,7 @@ modified_iterating_set.py:4:1: PLE4703 [*] Iterated set `nums` is modified withi 4 | / for num in nums: 5 | | nums.add(num + 1) | |_____________________^ PLE4703 -6 | +6 | 7 | animals = {"dog", "cat", "cow"} | = help: Iterate over a copy of `nums` @@ -29,7 +28,7 @@ modified_iterating_set.py:8:1: PLE4703 [*] Iterated set `animals` is modified wi 8 | / for animal in animals: 9 | | animals.pop("cow") | |______________________^ PLE4703 -10 | +10 | 11 | fruits = {"apple", "orange", "grape"} | = help: Iterate over a copy of `animals` @@ -50,7 +49,7 @@ modified_iterating_set.py:12:1: PLE4703 [*] Iterated set `fruits` is modified wi 12 | / for fruit in fruits: 13 | | fruits.clear() | |__________________^ PLE4703 -14 | +14 | 15 | planets = {"mercury", "venus", "earth"} | = help: Iterate over a copy of `fruits` @@ -71,7 +70,7 @@ modified_iterating_set.py:16:1: PLE4703 [*] Iterated set `planets` is modified w 16 | / for planet in planets: 17 | | planets.discard("mercury") | |______________________________^ PLE4703 -18 | +18 | 19 | colors = {"red", "green", "blue"} | = help: Iterate over a copy of `planets` @@ -92,7 +91,7 @@ modified_iterating_set.py:20:1: PLE4703 [*] Iterated set `colors` is modified wi 20 | / for color in colors: 21 | | colors.remove("red") | |________________________^ PLE4703 -22 | +22 | 23 | odds = {1, 3, 5} | = help: Iterate over a copy of `colors` @@ -114,7 +113,7 @@ modified_iterating_set.py:24:1: PLE4703 [*] Iterated set `odds` is modified with 25 | | if num > 1: 26 | | odds.add(num + 1) | |_________________________^ PLE4703 -27 | +27 | 28 | # OK | = help: Iterate over a copy of `odds` diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0124_comparison_with_itself.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0124_comparison_with_itself.py.snap index c657f71a9f302..6812c32fb405f 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0124_comparison_with_itself.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0124_comparison_with_itself.py.snap @@ -1,122 +1,121 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- comparison_with_itself.py:2:1: PLR0124 Name compared with itself, consider replacing `foo == foo` | 1 | # Errors. 2 | foo == foo | ^^^ PLR0124 -3 | +3 | 4 | foo != foo | comparison_with_itself.py:4:1: PLR0124 Name compared with itself, consider replacing `foo != foo` | 2 | foo == foo -3 | +3 | 4 | foo != foo | ^^^ PLR0124 -5 | +5 | 6 | foo > foo | comparison_with_itself.py:6:1: PLR0124 Name compared with itself, consider replacing `foo > foo` | 4 | foo != foo -5 | +5 | 6 | foo > foo | ^^^ PLR0124 -7 | +7 | 8 | foo >= foo | comparison_with_itself.py:8:1: PLR0124 Name compared with itself, consider replacing `foo >= foo` | 6 | foo > foo - 7 | + 7 | 8 | foo >= foo | ^^^ PLR0124 - 9 | + 9 | 10 | foo < foo | comparison_with_itself.py:10:1: PLR0124 Name compared with itself, consider replacing `foo < foo` | 8 | foo >= foo - 9 | + 9 | 10 | foo < foo | ^^^ PLR0124 -11 | +11 | 12 | foo <= foo | comparison_with_itself.py:12:1: PLR0124 Name compared with itself, consider replacing `foo <= foo` | 10 | foo < foo -11 | +11 | 12 | foo <= foo | ^^^ PLR0124 -13 | +13 | 14 | foo is foo | comparison_with_itself.py:14:1: PLR0124 Name compared with itself, consider replacing `foo is foo` | 12 | foo <= foo -13 | +13 | 14 | foo is foo | ^^^ PLR0124 -15 | +15 | 16 | foo is not foo | comparison_with_itself.py:16:1: PLR0124 Name compared with itself, consider replacing `foo is not foo` | 14 | foo is foo -15 | +15 | 16 | foo is not foo | ^^^ PLR0124 -17 | +17 | 18 | foo in foo | comparison_with_itself.py:18:1: PLR0124 Name compared with itself, consider replacing `foo in foo` | 16 | foo is not foo -17 | +17 | 18 | foo in foo | ^^^ PLR0124 -19 | +19 | 20 | foo not in foo | comparison_with_itself.py:20:1: PLR0124 Name compared with itself, consider replacing `foo not in foo` | 18 | foo in foo -19 | +19 | 20 | foo not in foo | ^^^ PLR0124 -21 | +21 | 22 | id(foo) == id(foo) | comparison_with_itself.py:22:1: PLR0124 Name compared with itself, consider replacing `id(foo) == id(foo)` | 20 | foo not in foo -21 | +21 | 22 | id(foo) == id(foo) | ^^^^^^^ PLR0124 -23 | +23 | 24 | len(foo) == len(foo) | comparison_with_itself.py:24:1: PLR0124 Name compared with itself, consider replacing `len(foo) == len(foo)` | 22 | id(foo) == id(foo) -23 | +23 | 24 | len(foo) == len(foo) | ^^^^^^^^ PLR0124 -25 | +25 | 26 | # Non-errors. | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0133_comparison_of_constant.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0133_comparison_of_constant.py.snap index aff14069c90fc..30bcc7a4f85c9 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0133_comparison_of_constant.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0133_comparison_of_constant.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- comparison_of_constant.py:3:4: PLR0133 Two constants compared in a comparison, consider replacing `100 == 100` | 1 | """Check that magic values are not used in comparisons""" -2 | +2 | 3 | if 100 == 100: # [comparison-of-constants] | ^^^ PLR0133 4 | pass @@ -14,7 +13,7 @@ comparison_of_constant.py:3:4: PLR0133 Two constants compared in a comparison, c comparison_of_constant.py:6:4: PLR0133 Two constants compared in a comparison, consider replacing `1 == 3` | 4 | pass -5 | +5 | 6 | if 1 == 3: # [comparison-of-constants] | ^ PLR0133 7 | pass @@ -23,7 +22,7 @@ comparison_of_constant.py:6:4: PLR0133 Two constants compared in a comparison, c comparison_of_constant.py:9:4: PLR0133 Two constants compared in a comparison, consider replacing `1 != 3` | 7 | pass - 8 | + 8 | 9 | if 1 != 3: # [comparison-of-constants] | ^ PLR0133 10 | pass @@ -40,7 +39,7 @@ comparison_of_constant.py:13:4: PLR0133 Two constants compared in a comparison, comparison_of_constant.py:23:4: PLR0133 Two constants compared in a comparison, consider replacing `1 > 0` | 21 | pass -22 | +22 | 23 | if 1 > 0: # [comparison-of-constants] | ^ PLR0133 24 | pass @@ -49,7 +48,7 @@ comparison_of_constant.py:23:4: PLR0133 Two constants compared in a comparison, comparison_of_constant.py:29:4: PLR0133 Two constants compared in a comparison, consider replacing `1 >= 0` | 27 | pass -28 | +28 | 29 | if 1 >= 0: # [comparison-of-constants] | ^ PLR0133 30 | pass @@ -58,7 +57,7 @@ comparison_of_constant.py:29:4: PLR0133 Two constants compared in a comparison, comparison_of_constant.py:35:4: PLR0133 Two constants compared in a comparison, consider replacing `1 < 0` | 33 | pass -34 | +34 | 35 | if 1 < 0: # [comparison-of-constants] | ^ PLR0133 36 | pass @@ -67,7 +66,7 @@ comparison_of_constant.py:35:4: PLR0133 Two constants compared in a comparison, comparison_of_constant.py:41:4: PLR0133 Two constants compared in a comparison, consider replacing `1 <= 0` | 39 | pass -40 | +40 | 41 | if 1 <= 0: # [comparison-of-constants] | ^ PLR0133 42 | pass @@ -76,7 +75,7 @@ comparison_of_constant.py:41:4: PLR0133 Two constants compared in a comparison, comparison_of_constant.py:51:4: PLR0133 Two constants compared in a comparison, consider replacing `"hello" == ""` | 49 | pass -50 | +50 | 51 | if "hello" == "": # [comparison-of-constants] | ^^^^^^^ PLR0133 52 | pass @@ -85,7 +84,7 @@ comparison_of_constant.py:51:4: PLR0133 Two constants compared in a comparison, comparison_of_constant.py:58:4: PLR0133 Two constants compared in a comparison, consider replacing `True == False` | 56 | pass -57 | +57 | 58 | if True == False: # [comparison-of-constants] | ^^^^ PLR0133 59 | pass diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0912_too_many_branches.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0912_too_many_branches.py.snap index d8655384467f7..ab698ec5d0229 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0912_too_many_branches.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0912_too_many_branches.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- too_many_branches.py:8:5: PLR0912 Too many branches (13 > 12) | @@ -14,7 +13,7 @@ too_many_branches.py:8:5: PLR0912 Too many branches (13 > 12) too_many_branches.py:80:5: PLR0912 Too many branches (13 > 12) | 78 | pass -79 | +79 | 80 | def with_statement_wrong(): | ^^^^^^^^^^^^^^^^^^^^ PLR0912 81 | """statements inside the with statement should get counted""" diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0917_too_many_positional_arguments.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0917_too_many_positional_arguments.py.snap index 293664ff3067c..43145d416a9c1 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0917_too_many_positional_arguments.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0917_too_many_positional_arguments.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- too_many_positional_arguments.py:1:5: PLR0917 Too many positional arguments (8/5) | @@ -26,7 +25,7 @@ too_many_positional_arguments.py:29:5: PLR0917 Too many positional arguments (6/ too_many_positional_arguments.py:43:9: PLR0917 Too many positional arguments (6/5) | 41 | pass -42 | +42 | 43 | def f(self, a, b, c, d, e, g): # Too many positional arguments (6/5) | ^ PLR0917 44 | pass diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap index 142e76e87f016..7e75b2ed09a97 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap @@ -6,7 +6,7 @@ repeated_equality_comparison.py:2:1: PLR1714 [*] Consider merging multiple compa 1 | # Errors. 2 | foo == "a" or foo == "b" | ^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -3 | +3 | 4 | foo != "a" and foo != "b" | = help: Merge multiple comparisons @@ -22,10 +22,10 @@ repeated_equality_comparison.py:2:1: PLR1714 [*] Consider merging multiple compa repeated_equality_comparison.py:4:1: PLR1714 [*] Consider merging multiple comparisons: `foo not in ("a", "b")`. Use a `set` if the elements are hashable. | 2 | foo == "a" or foo == "b" -3 | +3 | 4 | foo != "a" and foo != "b" | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -5 | +5 | 6 | foo == "a" or foo == "b" or foo == "c" | = help: Merge multiple comparisons @@ -43,10 +43,10 @@ repeated_equality_comparison.py:4:1: PLR1714 [*] Consider merging multiple compa repeated_equality_comparison.py:6:1: PLR1714 [*] Consider merging multiple comparisons: `foo in ("a", "b", "c")`. Use a `set` if the elements are hashable. | 4 | foo != "a" and foo != "b" -5 | +5 | 6 | foo == "a" or foo == "b" or foo == "c" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -7 | +7 | 8 | foo != "a" and foo != "b" and foo != "c" | = help: Merge multiple comparisons @@ -64,10 +64,10 @@ repeated_equality_comparison.py:6:1: PLR1714 [*] Consider merging multiple compa repeated_equality_comparison.py:8:1: PLR1714 [*] Consider merging multiple comparisons: `foo not in ("a", "b", "c")`. Use a `set` if the elements are hashable. | 6 | foo == "a" or foo == "b" or foo == "c" - 7 | + 7 | 8 | foo != "a" and foo != "b" and foo != "c" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 - 9 | + 9 | 10 | foo == a or foo == "b" or foo == 3 # Mixed types. | = help: Merge multiple comparisons @@ -85,10 +85,10 @@ repeated_equality_comparison.py:8:1: PLR1714 [*] Consider merging multiple compa repeated_equality_comparison.py:10:1: PLR1714 [*] Consider merging multiple comparisons: `foo in (a, "b", 3)`. Use a `set` if the elements are hashable. | 8 | foo != "a" and foo != "b" and foo != "c" - 9 | + 9 | 10 | foo == a or foo == "b" or foo == 3 # Mixed types. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -11 | +11 | 12 | "a" == foo or "b" == foo or "c" == foo | = help: Merge multiple comparisons @@ -106,10 +106,10 @@ repeated_equality_comparison.py:10:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:12:1: PLR1714 [*] Consider merging multiple comparisons: `foo in ("a", "b", "c")`. Use a `set` if the elements are hashable. | 10 | foo == a or foo == "b" or foo == 3 # Mixed types. -11 | +11 | 12 | "a" == foo or "b" == foo or "c" == foo | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -13 | +13 | 14 | "a" != foo and "b" != foo and "c" != foo | = help: Merge multiple comparisons @@ -127,10 +127,10 @@ repeated_equality_comparison.py:12:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:14:1: PLR1714 [*] Consider merging multiple comparisons: `foo not in ("a", "b", "c")`. Use a `set` if the elements are hashable. | 12 | "a" == foo or "b" == foo or "c" == foo -13 | +13 | 14 | "a" != foo and "b" != foo and "c" != foo | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -15 | +15 | 16 | "a" == foo or foo == "b" or "c" == foo | = help: Merge multiple comparisons @@ -148,10 +148,10 @@ repeated_equality_comparison.py:14:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:16:1: PLR1714 [*] Consider merging multiple comparisons: `foo in ("a", "b", "c")`. Use a `set` if the elements are hashable. | 14 | "a" != foo and "b" != foo and "c" != foo -15 | +15 | 16 | "a" == foo or foo == "b" or "c" == foo | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -17 | +17 | 18 | foo == bar or baz == foo or qux == foo | = help: Merge multiple comparisons @@ -169,10 +169,10 @@ repeated_equality_comparison.py:16:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:18:1: PLR1714 [*] Consider merging multiple comparisons: `foo in (bar, baz, qux)`. Use a `set` if the elements are hashable. | 16 | "a" == foo or foo == "b" or "c" == foo -17 | +17 | 18 | foo == bar or baz == foo or qux == foo | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -19 | +19 | 20 | foo == "a" or "b" == foo or foo == "c" | = help: Merge multiple comparisons @@ -190,10 +190,10 @@ repeated_equality_comparison.py:18:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:20:1: PLR1714 [*] Consider merging multiple comparisons: `foo in ("a", "b", "c")`. Use a `set` if the elements are hashable. | 18 | foo == bar or baz == foo or qux == foo -19 | +19 | 20 | foo == "a" or "b" == foo or foo == "c" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -21 | +21 | 22 | foo != "a" and "b" != foo and foo != "c" | = help: Merge multiple comparisons @@ -211,10 +211,10 @@ repeated_equality_comparison.py:20:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:22:1: PLR1714 [*] Consider merging multiple comparisons: `foo not in ("a", "b", "c")`. Use a `set` if the elements are hashable. | 20 | foo == "a" or "b" == foo or foo == "c" -21 | +21 | 22 | foo != "a" and "b" != foo and foo != "c" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -23 | +23 | 24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets | = help: Merge multiple comparisons @@ -232,10 +232,10 @@ repeated_equality_comparison.py:22:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:24:1: PLR1714 [*] Consider merging multiple comparisons: `foo in ("a", "b")`. Use a `set` if the elements are hashable. | 22 | foo != "a" and "b" != foo and foo != "c" -23 | +23 | 24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -25 | +25 | 26 | foo.bar == "a" or foo.bar == "b" # Attributes. | = help: Merge multiple comparisons @@ -253,10 +253,10 @@ repeated_equality_comparison.py:24:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:24:1: PLR1714 [*] Consider merging multiple comparisons: `bar in ("c", "d")`. Use a `set` if the elements are hashable. | 22 | foo != "a" and "b" != foo and foo != "c" -23 | +23 | 24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -25 | +25 | 26 | foo.bar == "a" or foo.bar == "b" # Attributes. | = help: Merge multiple comparisons @@ -274,10 +274,10 @@ repeated_equality_comparison.py:24:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:26:1: PLR1714 [*] Consider merging multiple comparisons: `foo.bar in ("a", "b")`. Use a `set` if the elements are hashable. | 24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets -25 | +25 | 26 | foo.bar == "a" or foo.bar == "b" # Attributes. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -27 | +27 | 28 | # OK | = help: Merge multiple comparisons @@ -295,10 +295,10 @@ repeated_equality_comparison.py:26:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:61:16: PLR1714 [*] Consider merging multiple comparisons: `bar in ("c", "d")`. Use a `set` if the elements are hashable. | 59 | foo == "a" or "c" == bar or foo == "b" or "d" == bar # Multiple targets -60 | +60 | 61 | foo == "a" or ("c" == bar or "d" == bar) or foo == "b" # Multiple targets | ^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -62 | +62 | 63 | foo == "a" or foo == "b" or "c" != bar and "d" != bar # Multiple targets | = help: Merge multiple comparisons @@ -316,10 +316,10 @@ repeated_equality_comparison.py:61:16: PLR1714 [*] Consider merging multiple com repeated_equality_comparison.py:63:1: PLR1714 [*] Consider merging multiple comparisons: `foo in ("a", "b")`. Use a `set` if the elements are hashable. | 61 | foo == "a" or ("c" == bar or "d" == bar) or foo == "b" # Multiple targets -62 | +62 | 63 | foo == "a" or foo == "b" or "c" != bar and "d" != bar # Multiple targets | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -64 | +64 | 65 | foo == "a" or ("c" != bar and "d" != bar) or foo == "b" # Multiple targets | = help: Merge multiple comparisons @@ -337,10 +337,10 @@ repeated_equality_comparison.py:63:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:63:29: PLR1714 [*] Consider merging multiple comparisons: `bar not in ("c", "d")`. Use a `set` if the elements are hashable. | 61 | foo == "a" or ("c" == bar or "d" == bar) or foo == "b" # Multiple targets -62 | +62 | 63 | foo == "a" or foo == "b" or "c" != bar and "d" != bar # Multiple targets | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -64 | +64 | 65 | foo == "a" or ("c" != bar and "d" != bar) or foo == "b" # Multiple targets | = help: Merge multiple comparisons @@ -358,10 +358,10 @@ repeated_equality_comparison.py:63:29: PLR1714 [*] Consider merging multiple com repeated_equality_comparison.py:65:16: PLR1714 [*] Consider merging multiple comparisons: `bar not in ("c", "d")`. Use a `set` if the elements are hashable. | 63 | foo == "a" or foo == "b" or "c" != bar and "d" != bar # Multiple targets -64 | +64 | 65 | foo == "a" or ("c" != bar and "d" != bar) or foo == "b" # Multiple targets | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -66 | +66 | 67 | foo == "a" and "c" != bar or foo == "b" and "d" != bar # Multiple targets | = help: Merge multiple comparisons @@ -379,10 +379,10 @@ repeated_equality_comparison.py:65:16: PLR1714 [*] Consider merging multiple com repeated_equality_comparison.py:69:1: PLR1714 [*] Consider merging multiple comparisons: `foo in (1, True)`. Use a `set` if the elements are hashable. | 67 | foo == "a" and "c" != bar or foo == "b" and "d" != bar # Multiple targets -68 | +68 | 69 | foo == 1 or foo == True # Different types, same hashed value | ^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -70 | +70 | 71 | foo == 1 or foo == 1.0 # Different types, same hashed value | = help: Merge multiple comparisons @@ -400,10 +400,10 @@ repeated_equality_comparison.py:69:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:71:1: PLR1714 [*] Consider merging multiple comparisons: `foo in (1, 1.0)`. Use a `set` if the elements are hashable. | 69 | foo == 1 or foo == True # Different types, same hashed value -70 | +70 | 71 | foo == 1 or foo == 1.0 # Different types, same hashed value | ^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -72 | +72 | 73 | foo == False or foo == 0 # Different types, same hashed value | = help: Merge multiple comparisons @@ -421,10 +421,10 @@ repeated_equality_comparison.py:71:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:73:1: PLR1714 [*] Consider merging multiple comparisons: `foo in (False, 0)`. Use a `set` if the elements are hashable. | 71 | foo == 1 or foo == 1.0 # Different types, same hashed value -72 | +72 | 73 | foo == False or foo == 0 # Different types, same hashed value | ^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -74 | +74 | 75 | foo == 0.0 or foo == 0j # Different types, same hashed value | = help: Merge multiple comparisons @@ -441,7 +441,7 @@ repeated_equality_comparison.py:73:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:75:1: PLR1714 [*] Consider merging multiple comparisons: `foo in (0.0, 0j)`. Use a `set` if the elements are hashable. | 73 | foo == False or foo == 0 # Different types, same hashed value -74 | +74 | 75 | foo == 0.0 or foo == 0j # Different types, same hashed value | ^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap index 906f9ad6c9c6c..986e16f9b216d 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- sys_exit_alias_1.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | 1 | import sys -2 | +2 | 3 | exit(0) | ^^^^ PLR1722 4 | quit(0) @@ -80,7 +79,7 @@ sys_exit_alias_1.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` sys_exit_alias_1.py:15:5: PLR1722 Use `sys.exit()` instead of `exit` | 13 | sys = 1 -14 | +14 | 15 | exit(1) | ^^^^ PLR1722 16 | quit(1) diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_11.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_11.py.snap index 8c3556438ba7c..3475c756f2b8f 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_11.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_11.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- sys_exit_alias_11.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | 1 | from sys import * -2 | +2 | 3 | exit(0) | ^^^^ PLR1722 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_12.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_12.py.snap index 956a1ed942573..081f770791f0b 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_12.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_12.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- sys_exit_alias_12.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | 1 | import os \ -2 | +2 | 3 | exit(0) | ^^^^ PLR1722 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap index 96d4b0f316228..fa77515597857 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- sys_exit_alias_2.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | 1 | import sys as sys2 -2 | +2 | 3 | exit(0) | ^^^^ PLR1722 4 | quit(0) diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap index 5c81a57432955..5f17881fe8d0f 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- sys_exit_alias_4.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | 1 | from sys import exit as exit2 -2 | +2 | 3 | exit(0) | ^^^^ PLR1722 4 | quit(0) diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_5.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_5.py.snap index d8b3a11512c07..99a789f9efbf9 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_5.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_5.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- sys_exit_alias_5.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | 1 | from sys import * -2 | +2 | 3 | exit(0) | ^^^^ PLR1722 4 | quit(0) diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1733_unnecessary_dict_index_lookup.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1733_unnecessary_dict_index_lookup.py.snap index dbbcead379ac0..44822f1e92ec5 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1733_unnecessary_dict_index_lookup.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1733_unnecessary_dict_index_lookup.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- unnecessary_dict_index_lookup.py:4:6: PLR1733 [*] Unnecessary lookup of dictionary value by key | @@ -48,7 +47,7 @@ unnecessary_dict_index_lookup.py:6:18: PLR1733 [*] Unnecessary lookup of diction 5 | {FRUITS[fruit_name] for fruit_name, fruit_count in FRUITS.items()} # PLR1733 6 | {fruit_name: FRUITS[fruit_name] for fruit_name, fruit_count in FRUITS.items()} # PLR1733 | ^^^^^^^^^^^^^^^^^^ PLR1733 -7 | +7 | 8 | for fruit_name, fruit_count in FRUITS.items(): | = help: Use existing variable diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1736_unnecessary_list_index_lookup.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1736_unnecessary_list_index_lookup.py.snap index f187241d63ae1..af6f0edc2651a 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1736_unnecessary_list_index_lookup.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1736_unnecessary_list_index_lookup.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- unnecessary_list_index_lookup.py:7:6: PLR1736 [*] List index lookup in `enumerate()` loop | @@ -48,7 +47,7 @@ unnecessary_list_index_lookup.py:9:14: PLR1736 [*] List index lookup in `enumera 8 | {letters[index] for index, letter in enumerate(letters)} # PLR1736 9 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736 | ^^^^^^^^^^^^^^ PLR1736 -10 | +10 | 11 | for index, letter in enumerate(letters): | = help: Use the loop variable directly @@ -109,7 +108,7 @@ unnecessary_list_index_lookup.py:14:16: PLR1736 [*] List index lookup in `enumer 13 | blah = letters[index] # PLR1736 14 | assert letters[index] == "d" # PLR1736 | ^^^^^^^^^^^^^^ PLR1736 -15 | +15 | 16 | for index, letter in builtins.enumerate(letters): | = help: Use the loop variable directly @@ -189,7 +188,7 @@ unnecessary_list_index_lookup.py:74:15: PLR1736 [*] List index lookup in `enumer 73 | for index, list_item in enumerate(some_list, start=0): 74 | print(some_list[index]) | ^^^^^^^^^^^^^^^^ PLR1736 -75 | +75 | 76 | # PLR1736 | = help: Use the loop variable directly diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2004_magic_value_comparison.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2004_magic_value_comparison.py.snap index 1c179c13114a4..d5b501687f5d0 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2004_magic_value_comparison.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2004_magic_value_comparison.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- magic_value_comparison.py:5:4: PLR2004 Magic value used in comparison, consider replacing `10` with a constant variable | 3 | user_input = 10 -4 | +4 | 5 | if 10 > user_input: # [magic-value-comparison] | ^^ PLR2004 6 | pass @@ -14,7 +13,7 @@ magic_value_comparison.py:5:4: PLR2004 Magic value used in comparison, consider magic_value_comparison.py:47:12: PLR2004 Magic value used in comparison, consider replacing `2` with a constant variable | 45 | pass -46 | +46 | 47 | if argc != 2: # [magic-value-comparison] | ^ PLR2004 48 | pass @@ -23,7 +22,7 @@ magic_value_comparison.py:47:12: PLR2004 Magic value used in comparison, conside magic_value_comparison.py:50:12: PLR2004 Magic value used in comparison, consider replacing `-2` with a constant variable | 48 | pass -49 | +49 | 50 | if argc != -2: # [magic-value-comparison] | ^^ PLR2004 51 | pass @@ -32,7 +31,7 @@ magic_value_comparison.py:50:12: PLR2004 Magic value used in comparison, conside magic_value_comparison.py:53:12: PLR2004 Magic value used in comparison, consider replacing `+2` with a constant variable | 51 | pass -52 | +52 | 53 | if argc != +2: # [magic-value-comparison] | ^^ PLR2004 54 | pass @@ -41,7 +40,7 @@ magic_value_comparison.py:53:12: PLR2004 Magic value used in comparison, conside magic_value_comparison.py:56:12: PLR2004 Magic value used in comparison, consider replacing `-2.0` with a constant variable | 54 | pass -55 | +55 | 56 | if argc != -2.0: # [magic-value-comparison] | ^^^^ PLR2004 57 | pass @@ -50,7 +49,7 @@ magic_value_comparison.py:56:12: PLR2004 Magic value used in comparison, conside magic_value_comparison.py:59:12: PLR2004 Magic value used in comparison, consider replacing `+2.0` with a constant variable | 57 | pass -58 | +58 | 59 | if argc != +2.0: # [magic-value-comparison] | ^^^^ PLR2004 60 | pass @@ -59,7 +58,7 @@ magic_value_comparison.py:59:12: PLR2004 Magic value used in comparison, conside magic_value_comparison.py:80:21: PLR2004 Magic value used in comparison, consider replacing `3.141592653589793238` with a constant variable | 78 | pi_estimation = 3.14 -79 | +79 | 80 | if pi_estimation == 3.141592653589793238: # [magic-value-comparison] | ^^^^^^^^^^^^^^^^^^^^ PLR2004 81 | pass @@ -68,7 +67,7 @@ magic_value_comparison.py:80:21: PLR2004 Magic value used in comparison, conside magic_value_comparison.py:86:21: PLR2004 Magic value used in comparison, consider replacing `0x3` with a constant variable | 84 | pass -85 | +85 | 86 | if pi_estimation == 0x3: # [magic-value-comparison] | ^^^ PLR2004 87 | pass diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2044_empty_comment.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2044_empty_comment.py.snap index 5b9ce7cf4ad12..5b1a959bda5d9 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2044_empty_comment.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2044_empty_comment.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- empty_comment.py:3:1: PLR2044 [*] Line with empty comment | @@ -46,7 +45,7 @@ empty_comment.py:5:9: PLR2044 [*] Line with empty comment 4 | # 5 | # | ^ PLR2044 -6 | +6 | 7 | # this non-empty comment has trailing whitespace and is OK | = help: Delete the empty comment @@ -81,7 +80,7 @@ empty_comment.py:18:11: PLR2044 [*] Line with empty comment empty_comment.py:44:1: PLR2044 [*] Line with empty comment | 42 | # These should be removed, despite being an empty "block comment". -43 | +43 | 44 | # | ^ PLR2044 45 | # @@ -102,7 +101,7 @@ empty_comment.py:45:1: PLR2044 [*] Line with empty comment 44 | # 45 | # | ^ PLR2044 -46 | +46 | 47 | # These should also be removed. | = help: Delete the empty comment diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6104_non_augmented_assignment.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6104_non_augmented_assignment.py.snap index 9255a220354bd..9de292825ba33 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6104_non_augmented_assignment.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6104_non_augmented_assignment.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- non_augmented_assignment.py:16:1: PLR6104 [*] Use `+=` to perform an augmented assignment directly | 14 | mat1, mat2 = None, None -15 | +15 | 16 | some_string = some_string + "a very long end of string" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 17 | index = index - 1 @@ -384,7 +383,7 @@ non_augmented_assignment.py:35:1: PLR6104 [*] Use `+=` to perform an augmented a 34 | mat1 = mat1 @ mat2 35 | a_list[1] = a_list[1] + 1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 -36 | +36 | 37 | a_list[0:2] = a_list[0:2] * 3 | = help: Replace with augmented assignment @@ -402,7 +401,7 @@ non_augmented_assignment.py:35:1: PLR6104 [*] Use `+=` to perform an augmented a non_augmented_assignment.py:37:1: PLR6104 [*] Use `*=` to perform an augmented assignment directly | 35 | a_list[1] = a_list[1] + 1 -36 | +36 | 37 | a_list[0:2] = a_list[0:2] * 3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 38 | a_list[:2] = a_list[:2] * 3 @@ -466,7 +465,7 @@ non_augmented_assignment.py:40:1: PLR6104 [*] Use `*=` to perform an augmented a 39 | a_list[1:] = a_list[1:] * 3 40 | a_list[:] = a_list[:] * 3 | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 -41 | +41 | 42 | index = index * (index + 10) | = help: Replace with augmented assignment @@ -484,7 +483,7 @@ non_augmented_assignment.py:40:1: PLR6104 [*] Use `*=` to perform an augmented a non_augmented_assignment.py:42:1: PLR6104 [*] Use `*=` to perform an augmented assignment directly | 40 | a_list[:] = a_list[:] * 3 -41 | +41 | 42 | index = index * (index + 10) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 | @@ -541,7 +540,7 @@ non_augmented_assignment.py:54:1: PLR6104 [*] Use `+=` to perform an augmented a | 54 | a = a+-1 | ^^^^^^^^ PLR6104 -55 | +55 | 56 | # Regression tests for https://github.com/astral-sh/ruff/issues/11672 | = help: Replace with augmented assignment @@ -562,7 +561,7 @@ non_augmented_assignment.py:58:1: PLR6104 [*] Use `+=` to perform an augmented a 57 | test = 0x5 58 | test = test + 0xBA | ^^^^^^^^^^^^^^^^^^ PLR6104 -59 | +59 | 60 | test2 = b"" | = help: Replace with augmented assignment @@ -582,7 +581,7 @@ non_augmented_assignment.py:61:1: PLR6104 [*] Use `+=` to perform an augmented a 60 | test2 = b"" 61 | test2 = test2 + b"\000" | ^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 -62 | +62 | 63 | test3 = "" | = help: Replace with augmented assignment @@ -603,7 +602,7 @@ non_augmented_assignment.py:64:1: PLR6104 [*] Use `+=` to perform an augmented a 64 | / test3 = test3 + ( a := R"" 65 | | f"oo" ) | |__________________________________^ PLR6104 -66 | +66 | 67 | test4 = [] | = help: Replace with augmented assignment @@ -626,7 +625,7 @@ non_augmented_assignment.py:68:1: PLR6104 [*] Use `+=` to perform an augmented a 70 | | range(10) 71 | | ) | |___________________^ PLR6104 -72 | +72 | 73 | test5 = test5 + ( | = help: Replace with augmented assignment @@ -644,14 +643,14 @@ non_augmented_assignment.py:68:1: PLR6104 [*] Use `+=` to perform an augmented a non_augmented_assignment.py:73:1: PLR6104 [*] Use `+=` to perform an augmented assignment directly | 71 | ) -72 | +72 | 73 | / test5 = test5 + ( 74 | | 4 75 | | * 76 | | 10 77 | | ) | |_^ PLR6104 -78 | +78 | 79 | test6 = test6 + \ | = help: Replace with augmented assignment @@ -669,7 +668,7 @@ non_augmented_assignment.py:73:1: PLR6104 [*] Use `+=` to perform an augmented a non_augmented_assignment.py:79:1: PLR6104 [*] Use `+=` to perform an augmented assignment directly | 77 | ) -78 | +78 | 79 | / test6 = test6 + \ 80 | | ( 81 | | 4 @@ -677,7 +676,7 @@ non_augmented_assignment.py:79:1: PLR6104 [*] Use `+=` to perform an augmented a 83 | | 10 84 | | ) | |_________^ PLR6104 -85 | +85 | 86 | test7 = \ | = help: Replace with augmented assignment @@ -696,12 +695,12 @@ non_augmented_assignment.py:79:1: PLR6104 [*] Use `+=` to perform an augmented a non_augmented_assignment.py:86:1: PLR6104 [*] Use `+=` to perform an augmented assignment directly | 84 | ) -85 | +85 | 86 | / test7 = \ 87 | | 100 \ 88 | | + test7 | |___________^ PLR6104 -89 | +89 | 90 | test8 = \ | = help: Replace with augmented assignment @@ -721,7 +720,7 @@ non_augmented_assignment.py:86:1: PLR6104 [*] Use `+=` to perform an augmented a non_augmented_assignment.py:90:1: PLR6104 [*] Use `+=` to perform an augmented assignment directly | 88 | + test7 -89 | +89 | 90 | / test8 = \ 91 | | 886 \ 92 | | + \ diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6201_literal_membership.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6201_literal_membership.py.snap index 0a05dcb711957..273ce58e09004 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6201_literal_membership.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6201_literal_membership.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- literal_membership.py:2:6: PLR6201 [*] Use a set literal when testing for membership | @@ -73,7 +72,7 @@ literal_membership.py:9:70: PLR6201 [*] Use a set literal when testing for membe 8 | "cherry" in fruits 9 | _ = {key: value for key, value in {"a": 1, "b": 2}.items() if key in ("a", "b")} | ^^^^^^^^^^ PLR6201 -10 | +10 | 11 | # OK | = help: Convert to `set` diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6301_no_self_use.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6301_no_self_use.py.snap index b1da0df29e8b3..e53bcc34e829f 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6301_no_self_use.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6301_no_self_use.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- no_self_use.py:7:9: PLR6301 Method `developer_greeting` could be a function, class method, or static method | @@ -13,7 +12,7 @@ no_self_use.py:7:9: PLR6301 Method `developer_greeting` could be a function, cla no_self_use.py:10:9: PLR6301 Method `greeting_1` could be a function, class method, or static method | 8 | print(f"Greetings {name}!") - 9 | + 9 | 10 | def greeting_1(self): # [no-self-use] | ^^^^^^^^^^ PLR6301 11 | print("Hello!") @@ -22,7 +21,7 @@ no_self_use.py:10:9: PLR6301 Method `greeting_1` could be a function, class meth no_self_use.py:13:9: PLR6301 Method `greeting_2` could be a function, class method, or static method | 11 | print("Hello!") -12 | +12 | 13 | def greeting_2(self): # [no-self-use] | ^^^^^^^^^^ PLR6301 14 | print("Hi!") diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0108_unnecessary_lambda.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0108_unnecessary_lambda.py.snap index 0bff37af89187..e4e25f27e649d 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0108_unnecessary_lambda.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0108_unnecessary_lambda.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- unnecessary_lambda.py:1:5: PLW0108 [*] Lambda may be unnecessary; consider inlining inner function | @@ -22,7 +21,7 @@ unnecessary_lambda.py:2:5: PLW0108 [*] Lambda may be unnecessary; consider inlin 1 | _ = lambda: print() # [unnecessary-lambda] 2 | _ = lambda x, y: min(x, y) # [unnecessary-lambda] | ^^^^^^^^^^^^^^^^^^^^^^ PLW0108 -3 | +3 | 4 | _ = lambda *args: f(*args) # [unnecessary-lambda] | = help: Inline function call @@ -38,7 +37,7 @@ unnecessary_lambda.py:2:5: PLW0108 [*] Lambda may be unnecessary; consider inlin unnecessary_lambda.py:4:5: PLW0108 [*] Lambda may be unnecessary; consider inlining inner function | 2 | _ = lambda x, y: min(x, y) # [unnecessary-lambda] -3 | +3 | 4 | _ = lambda *args: f(*args) # [unnecessary-lambda] | ^^^^^^^^^^^^^^^^^^^^^^ PLW0108 5 | _ = lambda **kwargs: f(**kwargs) # [unnecessary-lambda] @@ -102,7 +101,7 @@ unnecessary_lambda.py:7:5: PLW0108 [*] Lambda may be unnecessary; consider inlin 6 | _ = lambda *args, **kwargs: f(*args, **kwargs) # [unnecessary-lambda] 7 | _ = lambda x, y, z, *args, **kwargs: f(x, y, z, *args, **kwargs) # [unnecessary-lambda] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0108 -8 | +8 | 9 | _ = lambda x: f(lambda x: x)(x) # [unnecessary-lambda] | = help: Inline function call @@ -120,7 +119,7 @@ unnecessary_lambda.py:7:5: PLW0108 [*] Lambda may be unnecessary; consider inlin unnecessary_lambda.py:9:5: PLW0108 [*] Lambda may be unnecessary; consider inlining inner function | 7 | _ = lambda x, y, z, *args, **kwargs: f(x, y, z, *args, **kwargs) # [unnecessary-lambda] - 8 | + 8 | 9 | _ = lambda x: f(lambda x: x)(x) # [unnecessary-lambda] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0108 10 | _ = lambda x, y: f(lambda x, y: x + y)(x, y) # [unnecessary-lambda] @@ -142,7 +141,7 @@ unnecessary_lambda.py:10:5: PLW0108 [*] Lambda may be unnecessary; consider inli 9 | _ = lambda x: f(lambda x: x)(x) # [unnecessary-lambda] 10 | _ = lambda x, y: f(lambda x, y: x + y)(x, y) # [unnecessary-lambda] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0108 -11 | +11 | 12 | # default value in lambda parameters | = help: Inline function call diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0120_useless_else_on_loop.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0120_useless_else_on_loop.py.snap index 8d16fb473a7dc..0a03d7a4c441b 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0120_useless_else_on_loop.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0120_useless_else_on_loop.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- useless_else_on_loop.py:9:5: PLW0120 [*] `else` clause on loop without a `break` statement; remove the `else` and dedent its contents | @@ -49,7 +48,7 @@ useless_else_on_loop.py:18:5: PLW0120 [*] `else` clause on loop without a `break useless_else_on_loop.py:30:1: PLW0120 [*] `else` clause on loop without a `break` statement; remove the `else` and dedent its contents | 28 | break -29 | +29 | 30 | else: # [useless-else-on-loop] | ^^^^ PLW0120 31 | print("or else!") diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0127_self_assigning_variable.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0127_self_assigning_variable.py.snap index 6c9031d4c1414..e1489cb2ab472 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0127_self_assigning_variable.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0127_self_assigning_variable.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- self_assigning_variable.py:6:1: PLW0127 Self-assignment of variable `foo` | @@ -395,7 +394,7 @@ self_assigning_variable.py:28:2: PLW0127 Self-assignment of variable `foo` 27 | (foo, bar) = (foo, bar) = baz 28 | (foo, bar) = baz = (foo, bar) = 1 | ^^^ PLW0127 -29 | +29 | 30 | # Non-errors. | @@ -405,6 +404,6 @@ self_assigning_variable.py:28:7: PLW0127 Self-assignment of variable `bar` 27 | (foo, bar) = (foo, bar) = baz 28 | (foo, bar) = baz = (foo, bar) = 1 | ^^^ PLW0127 -29 | +29 | 30 | # Non-errors. | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0128_redeclared_assigned_name.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0128_redeclared_assigned_name.py.snap index 66b84a4bcc636..c3f54bdf9b68d 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0128_redeclared_assigned_name.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0128_redeclared_assigned_name.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- redeclared_assigned_name.py:1:8: PLW0128 Redeclared variable `FIRST` in assignment | @@ -43,7 +42,7 @@ redeclared_assigned_name.py:4:23: PLW0128 Redeclared variable `FIRST` in assignm 3 | FIRST, (FIRST, SECOND, (THIRD, FIRST)) = (1, (1, 2)) # PLW0128 4 | FIRST, SECOND, THIRD, FIRST, SECOND = (1, 2, 3, 4) # PLW0128 | ^^^^^ PLW0128 -5 | +5 | 6 | FIRST, SECOND, _, _, _ignored = (1, 2, 3, 4, 5) # OK | @@ -53,6 +52,6 @@ redeclared_assigned_name.py:4:30: PLW0128 Redeclared variable `SECOND` in assign 3 | FIRST, (FIRST, SECOND, (THIRD, FIRST)) = (1, (1, 2)) # PLW0128 4 | FIRST, SECOND, THIRD, FIRST, SECOND = (1, 2, 3, 4) # PLW0128 | ^^^^^^ PLW0128 -5 | +5 | 6 | FIRST, SECOND, _, _, _ignored = (1, 2, 3, 4, 5) # OK | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0129_assert_on_string_literal.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0129_assert_on_string_literal.py.snap index c4293a4ef0e2c..120302d3dfacb 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0129_assert_on_string_literal.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0129_assert_on_string_literal.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- assert_on_string_literal.py:3:12: PLW0129 Asserting on a non-empty string literal will always pass | @@ -25,7 +24,7 @@ assert_on_string_literal.py:14:12: PLW0129 Asserting on a non-empty string liter 13 | except: 14 | assert "bad again" # [assert-on-string-literal] | ^^^^^^^^^^^ PLW0129 -15 | +15 | 16 | a = 12 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0133_useless_exception_statement.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0133_useless_exception_statement.py.snap index 4593aa5e5406d..9df03f09946cc 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0133_useless_exception_statement.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0133_useless_exception_statement.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- useless_exception_statement.py:7:5: PLW0133 [*] Missing `raise` statement on exception | @@ -86,7 +85,7 @@ useless_exception_statement.py:34:9: PLW0133 [*] Missing `raise` statement on ex 33 | def inner(): 34 | IndexError("This is an exception") # PLW0133 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0133 -35 | +35 | 36 | inner() | = help: Add `raise` keyword @@ -218,10 +217,10 @@ useless_exception_statement.py:71:5: PLW0133 [*] Missing `raise` statement on ex useless_exception_statement.py:126:1: PLW0133 [*] Missing `raise` statement on exception | 124 | import builtins -125 | +125 | 126 | builtins.TypeError("still an exception even though it's an Attribute") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0133 -127 | +127 | 128 | PythonFinalizationError("Added in Python 3.13") | = help: Add `raise` keyword @@ -238,7 +237,7 @@ useless_exception_statement.py:126:1: PLW0133 [*] Missing `raise` statement on e useless_exception_statement.py:128:1: PLW0133 [*] Missing `raise` statement on exception | 126 | builtins.TypeError("still an exception even though it's an Attribute") -127 | +127 | 128 | PythonFinalizationError("Added in Python 3.13") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0133 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0602_global_variable_not_assigned.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0602_global_variable_not_assigned.py.snap index 40a663dc5bba4..3ba04a3cecd88 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0602_global_variable_not_assigned.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0602_global_variable_not_assigned.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- global_variable_not_assigned.py:5:12: PLW0602 Using global for `X` but no assignment is done | @@ -15,6 +14,6 @@ global_variable_not_assigned.py:9:12: PLW0602 Using global for `X` but no assign 8 | def f(): 9 | global X | ^ PLW0602 -10 | +10 | 11 | print(X) | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0603_global_statement.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0603_global_statement.py.snap index 8258c72238234..30959b0b116d5 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0603_global_statement.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0603_global_statement.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- global_statement.py:17:12: PLW0603 Using the global statement to update `CONSTANT` is discouraged | @@ -56,7 +55,7 @@ global_statement.py:50:12: PLW0603 Using the global statement to update `CONSTAN 49 | """Function assigns should only throw a global statement error""" 50 | global CONSTANT # [global-statement] | ^^^^^^^^ PLW0603 -51 | +51 | 52 | def CONSTANT(): | @@ -66,7 +65,7 @@ global_statement.py:60:12: PLW0603 Using the global statement to update `FUNC` i 59 | """Overriding a function should only throw a global statement error""" 60 | global FUNC # [global-statement] | ^^^^ PLW0603 -61 | +61 | 62 | def FUNC(): | @@ -76,7 +75,7 @@ global_statement.py:70:12: PLW0603 Using the global statement to update `CLASS` 69 | """Overriding a class should only throw a global statement error""" 70 | global CLASS # [global-statement] | ^^^^^ PLW0603 -71 | +71 | 72 | class CLASS: | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0604_global_at_module_level.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0604_global_at_module_level.py.snap index ef9766f7b3d09..7ca2dd0b69fe4 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0604_global_at_module_level.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0604_global_at_module_level.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- global_at_module_level.py:1:1: PLW0604 `global` at module level is redundant | 1 | global price # W0604 | ^^^^^^^^^^^^ PLW0604 -2 | +2 | 3 | price = 25 | @@ -15,6 +14,6 @@ global_at_module_level.py:6:5: PLW0604 `global` at module level is redundant 5 | if True: 6 | global X # W0604 | ^^^^^^^^ PLW0604 -7 | +7 | 8 | def no_error(): | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0642_self_or_cls_assignment.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0642_self_or_cls_assignment.py.snap index b6b4c7ff2daba..2192975c9aed5 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0642_self_or_cls_assignment.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0642_self_or_cls_assignment.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- self_or_cls_assignment.py:4:9: PLW0642 Reassigned `cls` variable in class method | @@ -62,7 +61,7 @@ self_or_cls_assignment.py:10:16: PLW0642 Reassigned `cls` variable in class meth 9 | blah, (cls, blah2) = "apple", ("orange", "banana") # PLW0642 10 | blah, [cls, blah2] = "apple", ("orange", "banana") # PLW0642 | ^^^ PLW0642 -11 | +11 | 12 | @classmethod | = help: Consider using a different variable name @@ -73,7 +72,7 @@ self_or_cls_assignment.py:14:9: PLW0642 Reassigned `cls` variable in class metho 13 | def add_fruits(cls, fruits, /) -> None: 14 | cls = fruits # PLW0642 | ^^^ PLW0642 -15 | +15 | 16 | def print_color(self) -> None: | = help: Consider using a different variable name @@ -137,7 +136,7 @@ self_or_cls_assignment.py:23:16: PLW0642 Reassigned `self` variable in instance 22 | blah, (self, blah2) = "apple", ("orange", "banana") # PLW0642 23 | blah, [self, blah2] = "apple", ("orange", "banana") # PLW0642 | ^^^^ PLW0642 -24 | +24 | 25 | def print_color(self, color, /) -> None: | = help: Consider using a different variable name @@ -147,7 +146,7 @@ self_or_cls_assignment.py:26:9: PLW0642 Reassigned `self` variable in instance m 25 | def print_color(self, color, /) -> None: 26 | self = color | ^^^^ PLW0642 -27 | +27 | 28 | def ok(self) -> None: | = help: Consider using a different variable name diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1501_bad_open_mode.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1501_bad_open_mode.py.snap index 6b93f039ff62a..6c19b91ebe449 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1501_bad_open_mode.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1501_bad_open_mode.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- bad_open_mode.py:11:12: PLW1501 `rwx` is not a valid mode for `open` | @@ -107,7 +106,7 @@ bad_open_mode.py:34:25: PLW1501 `rwx` is not a valid mode for `open` 33 | pathlib.Path(NAME).open(mode="rwx") # [bad-open-mode] 34 | pathlib.Path(NAME).open("rwx", encoding="utf-8") # [bad-open-mode] | ^^^^^ PLW1501 -35 | +35 | 36 | import builtins | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1507_shallow_copy_environ.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1507_shallow_copy_environ.py.snap index e6b1d9adb4ecf..c59f03fdf277f 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1507_shallow_copy_environ.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1507_shallow_copy_environ.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- shallow_copy_environ.py:4:14: PLW1507 [*] Shallow copy of `os.environ` via `copy.copy(os.environ)` | 2 | import os -3 | +3 | 4 | copied_env = copy.copy(os.environ) # [shallow-copy-environ] | ^^^^^^^^^^^^^^^^^^^^^ PLW1507 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1508_invalid_envvar_default.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1508_invalid_envvar_default.py.snap index 1b06d83baa9bb..b1fed4b4b9333 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1508_invalid_envvar_default.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1508_invalid_envvar_default.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- invalid_envvar_default.py:3:29: PLW1508 Invalid type for environment variable default; expected `str` or `None` | 1 | import os -2 | +2 | 3 | tempVar = os.getenv("TEST", 12) # [invalid-envvar-default] | ^^ PLW1508 4 | goodVar = os.getenv("TESTING", None) diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1509_subprocess_popen_preexec_fn.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1509_subprocess_popen_preexec_fn.py.snap index 8a03622b19242..9918c300e9cf0 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1509_subprocess_popen_preexec_fn.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1509_subprocess_popen_preexec_fn.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- subprocess_popen_preexec_fn.py:9:18: PLW1509 `preexec_fn` argument is unsafe when using threads | @@ -36,6 +35,6 @@ subprocess_popen_preexec_fn.py:12:26: PLW1509 `preexec_fn` argument is unsafe wh 11 | subprocess.Popen(preexec_fn=lambda: print("Hello, world!")) 12 | subprocess.Popen(["ls"], preexec_fn=lambda: print("Hello, world!")) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW1509 -13 | +13 | 14 | # Non-errors. | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1510_subprocess_run_without_check.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1510_subprocess_run_without_check.py.snap index 275cf6d41abf0..7e6539ec04c0b 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1510_subprocess_run_without_check.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1510_subprocess_run_without_check.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- subprocess_run_without_check.py:4:1: PLW1510 [*] `subprocess.run` without explicit `check` argument | @@ -70,7 +69,7 @@ subprocess_run_without_check.py:10:1: PLW1510 [*] `subprocess.run` without expli 9 | ) 10 | subprocess.run(["ls"], **kwargs) | ^^^^^^^^^^^^^^ PLW1510 -11 | +11 | 12 | # Non-errors. | = help: Add explicit `check=False` diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1514_unspecified_encoding.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1514_unspecified_encoding.py.snap index cd39d99241101..cc91be3fd94ae 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1514_unspecified_encoding.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1514_unspecified_encoding.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- unspecified_encoding.py:8:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument | @@ -132,7 +131,7 @@ unspecified_encoding.py:14:1: PLW1514 [*] `tempfile.SpooledTemporaryFile` in tex 13 | codecs.open("test.txt") 14 | tempfile.SpooledTemporaryFile(0, "w") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW1514 -15 | +15 | 16 | # Non-errors. | = help: Add explicit `encoding` argument @@ -150,7 +149,7 @@ unspecified_encoding.py:14:1: PLW1514 [*] `tempfile.SpooledTemporaryFile` in tex unspecified_encoding.py:46:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument | 44 | tempfile.SpooledTemporaryFile(0, ) -45 | +45 | 46 | open("test.txt",) | ^^^^ PLW1514 47 | open() @@ -296,7 +295,7 @@ unspecified_encoding.py:59:1: PLW1514 [*] `open` in text mode without explicit ` unspecified_encoding.py:64:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument | 62 | ) -63 | +63 | 64 | open((("test.txt")),) | ^^^^ PLW1514 65 | open( @@ -422,7 +421,7 @@ unspecified_encoding.py:80:1: PLW1514 [*] `pathlib.Path(...).write_text` without 79 | text = Path("foo.txt").read_text() 80 | Path("foo.txt").write_text(text) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW1514 -81 | +81 | 82 | # Non-errors. | = help: Add explicit `encoding` argument diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1641_eq_without_hash.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1641_eq_without_hash.py.snap index 33ba7d3796f8f..572aabdcbaf8d 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1641_eq_without_hash.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1641_eq_without_hash.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- eq_without_hash.py:3:7: PLW1641 Object does not implement `__hash__` method | 1 | ### Errors -2 | +2 | 3 | class Person: | ^^^^^^ PLW1641 4 | def __init__(self): diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW2101_useless_with_lock.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW2101_useless_with_lock.py.snap index 9adf2b8cf5178..8f42ef34e9eb9 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW2101_useless_with_lock.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW2101_useless_with_lock.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- useless_with_lock.py:5:6: PLW2101 Threading lock directly created in `with` statement has no effect | @@ -12,7 +11,7 @@ useless_with_lock.py:5:6: PLW2101 Threading lock directly created in `with` stat useless_with_lock.py:8:6: PLW2101 Threading lock directly created in `with` statement has no effect | 6 | ... -7 | +7 | 8 | with Lock(): # [useless-with-lock] | ^^^^^^ PLW2101 9 | ... @@ -21,7 +20,7 @@ useless_with_lock.py:8:6: PLW2101 Threading lock directly created in `with` stat useless_with_lock.py:11:6: PLW2101 Threading lock directly created in `with` statement has no effect | 9 | ... -10 | +10 | 11 | with threading.Lock() as this_shouldnt_matter: # [useless-with-lock] | ^^^^^^^^^^^^^^^^ PLW2101 12 | ... @@ -30,7 +29,7 @@ useless_with_lock.py:11:6: PLW2101 Threading lock directly created in `with` sta useless_with_lock.py:14:6: PLW2101 Threading lock directly created in `with` statement has no effect | 12 | ... -13 | +13 | 14 | with threading.RLock(): # [useless-with-lock] | ^^^^^^^^^^^^^^^^^ PLW2101 15 | ... @@ -39,7 +38,7 @@ useless_with_lock.py:14:6: PLW2101 Threading lock directly created in `with` sta useless_with_lock.py:17:6: PLW2101 Threading lock directly created in `with` statement has no effect | 15 | ... -16 | +16 | 17 | with RLock(): # [useless-with-lock] | ^^^^^^^ PLW2101 18 | ... @@ -48,7 +47,7 @@ useless_with_lock.py:17:6: PLW2101 Threading lock directly created in `with` sta useless_with_lock.py:20:6: PLW2101 Threading lock directly created in `with` statement has no effect | 18 | ... -19 | +19 | 20 | with threading.Condition(): # [useless-with-lock] | ^^^^^^^^^^^^^^^^^^^^^ PLW2101 21 | ... @@ -57,7 +56,7 @@ useless_with_lock.py:20:6: PLW2101 Threading lock directly created in `with` sta useless_with_lock.py:23:6: PLW2101 Threading lock directly created in `with` statement has no effect | 21 | ... -22 | +22 | 23 | with Condition(): # [useless-with-lock] | ^^^^^^^^^^^ PLW2101 24 | ... @@ -66,7 +65,7 @@ useless_with_lock.py:23:6: PLW2101 Threading lock directly created in `with` sta useless_with_lock.py:26:6: PLW2101 Threading lock directly created in `with` statement has no effect | 24 | ... -25 | +25 | 26 | with threading.Semaphore(): # [useless-with-lock] | ^^^^^^^^^^^^^^^^^^^^^ PLW2101 27 | ... @@ -75,7 +74,7 @@ useless_with_lock.py:26:6: PLW2101 Threading lock directly created in `with` sta useless_with_lock.py:29:6: PLW2101 Threading lock directly created in `with` statement has no effect | 27 | ... -28 | +28 | 29 | with Semaphore(): # [useless-with-lock] | ^^^^^^^^^^^ PLW2101 30 | ... @@ -84,7 +83,7 @@ useless_with_lock.py:29:6: PLW2101 Threading lock directly created in `with` sta useless_with_lock.py:32:6: PLW2101 Threading lock directly created in `with` statement has no effect | 30 | ... -31 | +31 | 32 | with threading.BoundedSemaphore(): # [useless-with-lock] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW2101 33 | ... @@ -93,7 +92,7 @@ useless_with_lock.py:32:6: PLW2101 Threading lock directly created in `with` sta useless_with_lock.py:35:6: PLW2101 Threading lock directly created in `with` statement has no effect | 33 | ... -34 | +34 | 35 | with BoundedSemaphore(): # [useless-with-lock] | ^^^^^^^^^^^^^^^^^^ PLW2101 36 | ... diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW2901_redefined_loop_name.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW2901_redefined_loop_name.py.snap index e834d0c89ffd3..8bb2aff29ee95 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW2901_redefined_loop_name.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW2901_redefined_loop_name.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- redefined_loop_name.py:6:9: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target | @@ -90,7 +89,7 @@ redefined_loop_name.py:67:5: PLW2901 `for` loop variable `i` overwritten by assi 66 | i = typing.cast(int, i) 67 | i = 5 # error | ^ PLW2901 -68 | +68 | 69 | # For -> augmented assignment | @@ -100,7 +99,7 @@ redefined_loop_name.py:71:5: PLW2901 `for` loop variable `i` overwritten by assi 70 | for i in []: 71 | i += 5 # error | ^ PLW2901 -72 | +72 | 73 | # For -> annotated assignment | @@ -110,7 +109,7 @@ redefined_loop_name.py:75:5: PLW2901 `for` loop variable `i` overwritten by assi 74 | for i in []: 75 | i: int = 5 # error | ^ PLW2901 -76 | +76 | 77 | # For -> annotated assignment without value | @@ -183,7 +182,7 @@ redefined_loop_name.py:137:13: PLW2901 `for` loop variable `i` overwritten by as 136 | for i in []: # no error 137 | i = 2 # error | ^ PLW2901 -138 | +138 | 139 | # For -> class definition -> for -> for | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3201_bad_dunder_method_name.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3201_bad_dunder_method_name.py.snap index 1ac8bee6ed060..407fa4b92dc55 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3201_bad_dunder_method_name.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3201_bad_dunder_method_name.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- bad_dunder_method_name.py:5:9: PLW3201 Dunder method `_init_` has no special meaning in Python 3 | @@ -13,7 +12,7 @@ bad_dunder_method_name.py:5:9: PLW3201 Dunder method `_init_` has no special mea bad_dunder_method_name.py:8:9: PLW3201 Dunder method `__hello__` has no special meaning in Python 3 | 6 | pass -7 | +7 | 8 | def __hello__(self): # [bad-dunder-name] | ^^^^^^^^^ PLW3201 9 | print("hello") @@ -22,7 +21,7 @@ bad_dunder_method_name.py:8:9: PLW3201 Dunder method `__hello__` has no special bad_dunder_method_name.py:11:9: PLW3201 Dunder method `__init_` has no special meaning in Python 3 | 9 | print("hello") -10 | +10 | 11 | def __init_(self): # [bad-dunder-name] | ^^^^^^^ PLW3201 12 | # author likely unintentionally misspelled the correct init dunder. @@ -32,7 +31,7 @@ bad_dunder_method_name.py:11:9: PLW3201 Dunder method `__init_` has no special m bad_dunder_method_name.py:15:9: PLW3201 Dunder method `_init_` has no special meaning in Python 3 | 13 | pass -14 | +14 | 15 | def _init_(self): # [bad-dunder-name] | ^^^^^^ PLW3201 16 | # author likely unintentionally misspelled the correct init dunder. @@ -42,7 +41,7 @@ bad_dunder_method_name.py:15:9: PLW3201 Dunder method `_init_` has no special me bad_dunder_method_name.py:19:9: PLW3201 Dunder method `___neg__` has no special meaning in Python 3 | 17 | pass -18 | +18 | 19 | def ___neg__(self): # [bad-dunder-name] | ^^^^^^^^ PLW3201 20 | # author likely accidentally added an additional `_` @@ -52,7 +51,7 @@ bad_dunder_method_name.py:19:9: PLW3201 Dunder method `___neg__` has no special bad_dunder_method_name.py:23:9: PLW3201 Dunder method `__inv__` has no special meaning in Python 3 | 21 | pass -22 | +22 | 23 | def __inv__(self): # [bad-dunder-name] | ^^^^^^^ PLW3201 24 | # author likely meant to call the invert dunder method diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3301_nested_min_max.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3301_nested_min_max.py.snap index b4043cd22f559..af86b45d1d4c9 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3301_nested_min_max.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3301_nested_min_max.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- nested_min_max.py:2:1: PLW3301 [*] Nested `min` calls can be flattened | @@ -148,7 +147,7 @@ nested_min_max.py:9:1: PLW3301 [*] Nested `max` calls can be flattened 8 | max(1, max(2, max(3, 4))) 9 | max(1, foo("a", "b"), max(3, 4)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 -10 | +10 | 11 | # These should not trigger; we do not flag cases with keyword args. | = help: Flatten nested `max` calls @@ -169,7 +168,7 @@ nested_min_max.py:15:1: PLW3301 [*] Nested `min` calls can be flattened 14 | # This will still trigger, to merge the calls without keyword args. 15 | min(1, min(2, 3, key=test), min(4, 5)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 -16 | +16 | 17 | # Don't provide a fix if there are comments within the call. | = help: Flatten nested `min` calls @@ -192,7 +191,7 @@ nested_min_max.py:18:1: PLW3301 Nested `min` calls can be flattened 20 | | min(2, 3), 21 | | ) | |_^ PLW3301 -22 | +22 | 23 | # Handle iterable expressions. | = help: Flatten nested `min` calls @@ -264,7 +263,7 @@ nested_min_max.py:27:1: PLW3301 [*] Nested `max` calls can be flattened 26 | max(1, max(a)) 27 | max(1, max(i for i in range(10))) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 -28 | +28 | 29 | tuples_list = [ | = help: Flatten nested `max` calls @@ -284,7 +283,7 @@ nested_min_max.py:41:1: PLW3301 [*] Nested `max` calls can be flattened 40 | # Starred argument should be copied as it is. 41 | max(1, max(*a)) | ^^^^^^^^^^^^^^^ PLW3301 -42 | +42 | 43 | import builtins | = help: Flatten nested `max` calls @@ -326,7 +325,7 @@ nested_min_max.py:48:16: PLW3301 [*] Nested `max` calls can be flattened 50 | | len("Done!"), 51 | | ) | |_^ PLW3301 -52 | +52 | 53 | # OK | = help: Flatten nested `max` calls diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__allow_magic_value_types.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__allow_magic_value_types.snap index f857130221955..6d6a223c1121c 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__allow_magic_value_types.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__allow_magic_value_types.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- magic_value_comparison.py:56:12: PLR2004 Magic value used in comparison, consider replacing `-2.0` with a constant variable | 54 | pass -55 | +55 | 56 | if argc != -2.0: # [magic-value-comparison] | ^^^^ PLR2004 57 | pass @@ -14,7 +13,7 @@ magic_value_comparison.py:56:12: PLR2004 Magic value used in comparison, conside magic_value_comparison.py:59:12: PLR2004 Magic value used in comparison, consider replacing `+2.0` with a constant variable | 57 | pass -58 | +58 | 59 | if argc != +2.0: # [magic-value-comparison] | ^^^^ PLR2004 60 | pass @@ -23,7 +22,7 @@ magic_value_comparison.py:59:12: PLR2004 Magic value used in comparison, conside magic_value_comparison.py:74:22: PLR2004 Magic value used in comparison, consider replacing `"Hunter2"` with a constant variable | 72 | pass -73 | +73 | 74 | if input_password == "Hunter2": # correct | ^^^^^^^^^ PLR2004 75 | pass @@ -32,7 +31,7 @@ magic_value_comparison.py:74:22: PLR2004 Magic value used in comparison, conside magic_value_comparison.py:80:21: PLR2004 Magic value used in comparison, consider replacing `3.141592653589793238` with a constant variable | 78 | pi_estimation = 3.14 -79 | +79 | 80 | if pi_estimation == 3.141592653589793238: # [magic-value-comparison] | ^^^^^^^^^^^^^^^^^^^^ PLR2004 81 | pass @@ -41,7 +40,7 @@ magic_value_comparison.py:80:21: PLR2004 Magic value used in comparison, conside magic_value_comparison.py:92:18: PLR2004 Magic value used in comparison, consider replacing `b"something"` with a constant variable | 90 | user_input = b"Hello, There!" -91 | +91 | 92 | if user_input == b"something": # correct | ^^^^^^^^^^^^ PLR2004 93 | pass diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__continue_in_finally.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__continue_in_finally.snap index 6a195c7775daf..2391a6f9d4bf9 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__continue_in_finally.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__continue_in_finally.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- continue_in_finally.py:5:9: PLE0116 `continue` not supported inside `finally` clause | @@ -8,7 +7,7 @@ continue_in_finally.py:5:9: PLE0116 `continue` not supported inside `finally` cl 4 | finally: 5 | continue # [continue-in-finally] | ^^^^^^^^ PLE0116 -6 | +6 | 7 | while True: | @@ -27,7 +26,7 @@ continue_in_finally.py:26:17: PLE0116 `continue` not supported inside `finally` 25 | case "aa": 26 | continue # [continue-in-finally] | ^^^^^^^^ PLE0116 -27 | +27 | 28 | while True: | @@ -37,7 +36,7 @@ continue_in_finally.py:33:13: PLE0116 `continue` not supported inside `finally` 32 | with "aa" as f: 33 | continue # [continue-in-finally] | ^^^^^^^^ PLE0116 -34 | +34 | 35 | while True: | @@ -56,7 +55,7 @@ continue_in_finally.py:41:9: PLE0116 `continue` not supported inside `finally` c 40 | continue # [continue-in-finally] 41 | continue # [continue-in-finally] | ^^^^^^^^ PLE0116 -42 | +42 | 43 | def test(): | @@ -74,7 +73,7 @@ continue_in_finally.py:56:9: PLE0116 `continue` not supported inside `finally` c 55 | finally: 56 | continue # [continue-in-finally] | ^^^^^^^^ PLE0116 -57 | +57 | 58 | def test(): | @@ -84,7 +83,7 @@ continue_in_finally.py:69:9: PLE0116 `continue` not supported inside `finally` c 68 | continue 69 | continue # [continue-in-finally] | ^^^^^^^^ PLE0116 -70 | +70 | 71 | while True: | @@ -94,7 +93,7 @@ continue_in_finally.py:74:13: PLE0116 `continue` not supported inside `finally` 73 | else: 74 | continue # [continue-in-finally] | ^^^^^^^^ PLE0116 -75 | +75 | 76 | def test(): | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_branches.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_branches.snap index 10c8978d841f3..bcfd72f36acff 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_branches.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_branches.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- too_many_branches_params.py:6:5: PLR0912 Too many branches (2 > 1) | @@ -13,7 +12,7 @@ too_many_branches_params.py:6:5: PLR0912 Too many branches (2 > 1) too_many_branches_params.py:15:9: PLR0912 Too many branches (2 > 1) | 13 | return -14 | +14 | 15 | def i(x): | ^ PLR0912 16 | if x: diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__preview__PLR1714_repeated_equality_comparison.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__preview__PLR1714_repeated_equality_comparison.py.snap index 02c5e92cb799d..8c988f02f717d 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__preview__PLR1714_repeated_equality_comparison.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__preview__PLR1714_repeated_equality_comparison.py.snap @@ -6,7 +6,7 @@ repeated_equality_comparison.py:2:1: PLR1714 [*] Consider merging multiple compa 1 | # Errors. 2 | foo == "a" or foo == "b" | ^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -3 | +3 | 4 | foo != "a" and foo != "b" | = help: Merge multiple comparisons @@ -22,10 +22,10 @@ repeated_equality_comparison.py:2:1: PLR1714 [*] Consider merging multiple compa repeated_equality_comparison.py:4:1: PLR1714 [*] Consider merging multiple comparisons: `foo not in {"a", "b"}`. | 2 | foo == "a" or foo == "b" -3 | +3 | 4 | foo != "a" and foo != "b" | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -5 | +5 | 6 | foo == "a" or foo == "b" or foo == "c" | = help: Merge multiple comparisons @@ -43,10 +43,10 @@ repeated_equality_comparison.py:4:1: PLR1714 [*] Consider merging multiple compa repeated_equality_comparison.py:6:1: PLR1714 [*] Consider merging multiple comparisons: `foo in {"a", "b", "c"}`. | 4 | foo != "a" and foo != "b" -5 | +5 | 6 | foo == "a" or foo == "b" or foo == "c" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -7 | +7 | 8 | foo != "a" and foo != "b" and foo != "c" | = help: Merge multiple comparisons @@ -64,10 +64,10 @@ repeated_equality_comparison.py:6:1: PLR1714 [*] Consider merging multiple compa repeated_equality_comparison.py:8:1: PLR1714 [*] Consider merging multiple comparisons: `foo not in {"a", "b", "c"}`. | 6 | foo == "a" or foo == "b" or foo == "c" - 7 | + 7 | 8 | foo != "a" and foo != "b" and foo != "c" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 - 9 | + 9 | 10 | foo == a or foo == "b" or foo == 3 # Mixed types. | = help: Merge multiple comparisons @@ -85,10 +85,10 @@ repeated_equality_comparison.py:8:1: PLR1714 [*] Consider merging multiple compa repeated_equality_comparison.py:10:1: PLR1714 [*] Consider merging multiple comparisons: `foo in (a, "b", 3)`. Use a `set` if the elements are hashable. | 8 | foo != "a" and foo != "b" and foo != "c" - 9 | + 9 | 10 | foo == a or foo == "b" or foo == 3 # Mixed types. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -11 | +11 | 12 | "a" == foo or "b" == foo or "c" == foo | = help: Merge multiple comparisons @@ -106,10 +106,10 @@ repeated_equality_comparison.py:10:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:12:1: PLR1714 [*] Consider merging multiple comparisons: `foo in {"a", "b", "c"}`. | 10 | foo == a or foo == "b" or foo == 3 # Mixed types. -11 | +11 | 12 | "a" == foo or "b" == foo or "c" == foo | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -13 | +13 | 14 | "a" != foo and "b" != foo and "c" != foo | = help: Merge multiple comparisons @@ -127,10 +127,10 @@ repeated_equality_comparison.py:12:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:14:1: PLR1714 [*] Consider merging multiple comparisons: `foo not in {"a", "b", "c"}`. | 12 | "a" == foo or "b" == foo or "c" == foo -13 | +13 | 14 | "a" != foo and "b" != foo and "c" != foo | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -15 | +15 | 16 | "a" == foo or foo == "b" or "c" == foo | = help: Merge multiple comparisons @@ -148,10 +148,10 @@ repeated_equality_comparison.py:14:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:16:1: PLR1714 [*] Consider merging multiple comparisons: `foo in {"a", "b", "c"}`. | 14 | "a" != foo and "b" != foo and "c" != foo -15 | +15 | 16 | "a" == foo or foo == "b" or "c" == foo | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -17 | +17 | 18 | foo == bar or baz == foo or qux == foo | = help: Merge multiple comparisons @@ -169,10 +169,10 @@ repeated_equality_comparison.py:16:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:18:1: PLR1714 [*] Consider merging multiple comparisons: `foo in (bar, baz, qux)`. Use a `set` if the elements are hashable. | 16 | "a" == foo or foo == "b" or "c" == foo -17 | +17 | 18 | foo == bar or baz == foo or qux == foo | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -19 | +19 | 20 | foo == "a" or "b" == foo or foo == "c" | = help: Merge multiple comparisons @@ -190,10 +190,10 @@ repeated_equality_comparison.py:18:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:20:1: PLR1714 [*] Consider merging multiple comparisons: `foo in {"a", "b", "c"}`. | 18 | foo == bar or baz == foo or qux == foo -19 | +19 | 20 | foo == "a" or "b" == foo or foo == "c" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -21 | +21 | 22 | foo != "a" and "b" != foo and foo != "c" | = help: Merge multiple comparisons @@ -211,10 +211,10 @@ repeated_equality_comparison.py:20:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:22:1: PLR1714 [*] Consider merging multiple comparisons: `foo not in {"a", "b", "c"}`. | 20 | foo == "a" or "b" == foo or foo == "c" -21 | +21 | 22 | foo != "a" and "b" != foo and foo != "c" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -23 | +23 | 24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets | = help: Merge multiple comparisons @@ -232,10 +232,10 @@ repeated_equality_comparison.py:22:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:24:1: PLR1714 [*] Consider merging multiple comparisons: `foo in {"a", "b"}`. | 22 | foo != "a" and "b" != foo and foo != "c" -23 | +23 | 24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -25 | +25 | 26 | foo.bar == "a" or foo.bar == "b" # Attributes. | = help: Merge multiple comparisons @@ -253,10 +253,10 @@ repeated_equality_comparison.py:24:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:24:1: PLR1714 [*] Consider merging multiple comparisons: `bar in {"c", "d"}`. | 22 | foo != "a" and "b" != foo and foo != "c" -23 | +23 | 24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -25 | +25 | 26 | foo.bar == "a" or foo.bar == "b" # Attributes. | = help: Merge multiple comparisons @@ -274,10 +274,10 @@ repeated_equality_comparison.py:24:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:26:1: PLR1714 [*] Consider merging multiple comparisons: `foo.bar in {"a", "b"}`. | 24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets -25 | +25 | 26 | foo.bar == "a" or foo.bar == "b" # Attributes. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -27 | +27 | 28 | # OK | = help: Merge multiple comparisons @@ -295,10 +295,10 @@ repeated_equality_comparison.py:26:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:61:16: PLR1714 [*] Consider merging multiple comparisons: `bar in {"c", "d"}`. | 59 | foo == "a" or "c" == bar or foo == "b" or "d" == bar # Multiple targets -60 | +60 | 61 | foo == "a" or ("c" == bar or "d" == bar) or foo == "b" # Multiple targets | ^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -62 | +62 | 63 | foo == "a" or foo == "b" or "c" != bar and "d" != bar # Multiple targets | = help: Merge multiple comparisons @@ -316,10 +316,10 @@ repeated_equality_comparison.py:61:16: PLR1714 [*] Consider merging multiple com repeated_equality_comparison.py:63:1: PLR1714 [*] Consider merging multiple comparisons: `foo in {"a", "b"}`. | 61 | foo == "a" or ("c" == bar or "d" == bar) or foo == "b" # Multiple targets -62 | +62 | 63 | foo == "a" or foo == "b" or "c" != bar and "d" != bar # Multiple targets | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -64 | +64 | 65 | foo == "a" or ("c" != bar and "d" != bar) or foo == "b" # Multiple targets | = help: Merge multiple comparisons @@ -337,10 +337,10 @@ repeated_equality_comparison.py:63:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:63:29: PLR1714 [*] Consider merging multiple comparisons: `bar not in {"c", "d"}`. | 61 | foo == "a" or ("c" == bar or "d" == bar) or foo == "b" # Multiple targets -62 | +62 | 63 | foo == "a" or foo == "b" or "c" != bar and "d" != bar # Multiple targets | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -64 | +64 | 65 | foo == "a" or ("c" != bar and "d" != bar) or foo == "b" # Multiple targets | = help: Merge multiple comparisons @@ -358,10 +358,10 @@ repeated_equality_comparison.py:63:29: PLR1714 [*] Consider merging multiple com repeated_equality_comparison.py:65:16: PLR1714 [*] Consider merging multiple comparisons: `bar not in {"c", "d"}`. | 63 | foo == "a" or foo == "b" or "c" != bar and "d" != bar # Multiple targets -64 | +64 | 65 | foo == "a" or ("c" != bar and "d" != bar) or foo == "b" # Multiple targets | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -66 | +66 | 67 | foo == "a" and "c" != bar or foo == "b" and "d" != bar # Multiple targets | = help: Merge multiple comparisons @@ -379,10 +379,10 @@ repeated_equality_comparison.py:65:16: PLR1714 [*] Consider merging multiple com repeated_equality_comparison.py:69:1: PLR1714 [*] Consider merging multiple comparisons: `foo in {1, True}`. | 67 | foo == "a" and "c" != bar or foo == "b" and "d" != bar # Multiple targets -68 | +68 | 69 | foo == 1 or foo == True # Different types, same hashed value | ^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -70 | +70 | 71 | foo == 1 or foo == 1.0 # Different types, same hashed value | = help: Merge multiple comparisons @@ -400,10 +400,10 @@ repeated_equality_comparison.py:69:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:71:1: PLR1714 [*] Consider merging multiple comparisons: `foo in {1, 1.0}`. | 69 | foo == 1 or foo == True # Different types, same hashed value -70 | +70 | 71 | foo == 1 or foo == 1.0 # Different types, same hashed value | ^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -72 | +72 | 73 | foo == False or foo == 0 # Different types, same hashed value | = help: Merge multiple comparisons @@ -421,10 +421,10 @@ repeated_equality_comparison.py:71:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:73:1: PLR1714 [*] Consider merging multiple comparisons: `foo in {False, 0}`. | 71 | foo == 1 or foo == 1.0 # Different types, same hashed value -72 | +72 | 73 | foo == False or foo == 0 # Different types, same hashed value | ^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -74 | +74 | 75 | foo == 0.0 or foo == 0j # Different types, same hashed value | = help: Merge multiple comparisons @@ -441,7 +441,7 @@ repeated_equality_comparison.py:73:1: PLR1714 [*] Consider merging multiple comp repeated_equality_comparison.py:75:1: PLR1714 [*] Consider merging multiple comparisons: `foo in {0.0, 0j}`. | 73 | foo == False or foo == 0 # Different types, same hashed value -74 | +74 | 75 | foo == 0.0 or foo == 0j # Different types, same hashed value | ^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__preview__PLW1508_invalid_envvar_default.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__preview__PLW1508_invalid_envvar_default.py.snap index 7bc7aeaa45692..0ad2917d0ca3b 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__preview__PLW1508_invalid_envvar_default.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__preview__PLW1508_invalid_envvar_default.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- invalid_envvar_default.py:3:29: PLW1508 Invalid type for environment variable default; expected `str` or `None` | 1 | import os -2 | +2 | 3 | tempVar = os.getenv("TEST", 12) # [invalid-envvar-default] | ^^ PLW1508 4 | goodVar = os.getenv("TESTING", None) diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__too_many_public_methods.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__too_many_public_methods.snap index 7e43934f1f794..6eff6362b5e89 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__too_many_public_methods.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__too_many_public_methods.snap @@ -5,37 +5,37 @@ too_many_public_methods.py:4:1: PLR0904 Too many public methods (10 > 7) | 4 | / class Everything: 5 | | foo = 1 - 6 | | + 6 | | 7 | | def __init__(self): 8 | | pass - 9 | | + 9 | | 10 | | def _private(self): 11 | | pass -12 | | +12 | | 13 | | def method1(self): 14 | | pass -15 | | +15 | | 16 | | def method2(self): 17 | | pass -18 | | +18 | | 19 | | def method3(self): 20 | | pass -21 | | +21 | | 22 | | def method4(self): 23 | | pass -24 | | +24 | | 25 | | def method5(self): 26 | | pass -27 | | +27 | | 28 | | def method6(self): 29 | | pass -30 | | +30 | | 31 | | def method7(self): 32 | | pass -33 | | +33 | | 34 | | def method8(self): 35 | | pass -36 | | +36 | | 37 | | def method9(self): 38 | | pass | |____________^ PLR0904 diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP001.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP001.py.snap index 92cfb8e02184d..e0964e0a049ce 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP001.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP001.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP001.py:2:5: UP001 [*] `__metaclass__ = type` is implied | @@ -23,7 +22,7 @@ UP001.py:6:5: UP001 [*] `__metaclass__ = type` is implied 5 | class B: 6 | __metaclass__ = type | ^^^^^^^^^^^^^^^^^^^^ UP001 -7 | +7 | 8 | def __init__(self) -> None: | = help: Remove `__metaclass__ = type` diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP003.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP003.py.snap index 000e7e2b2e49b..d11e176201752 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP003.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP003.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP003.py:1:1: UP003 [*] Use `str` instead of `type(...)` | @@ -82,7 +81,7 @@ UP003.py:5:1: UP003 [*] Use `complex` instead of `type(...)` 4 | type(0.0) 5 | type(0j) | ^^^^^^^^ UP003 -6 | +6 | 7 | # OK | = help: Replace `type(...)` with `complex` diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP004.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP004.py.snap index e042b8c1ff024..7c4eabfa7bd7d 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP004.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP004.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP004.py:5:9: UP004 [*] Class `A` inherits from `object` | @@ -494,7 +493,7 @@ UP004.py:146:9: UP004 [*] Class `A` inherits from `object` UP004.py:159:15: UP004 [*] Class `Unusual` inherits from `object` | 157 | import builtins -158 | +158 | 159 | class Unusual(builtins.object): | ^^^^^^^^^^^^^^^ UP004 160 | ... diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_0.py.snap index 7084576892d79..496c05b80457a 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_0.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP009_0.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary | 1 | # coding=utf8 | ^^^^^^^^^^^^^ UP009 -2 | +2 | 3 | print("Hello world") | = help: Remove unnecessary coding comment diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_1.py.snap index 62c16d74a6bb9..5b64115e35584 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_1.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_1.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP009_1.py:2:1: UP009 [*] UTF-8 encoding declaration is unnecessary | 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- | ^^^^^^^^^^^^^^^^^^^^^^^ UP009 -3 | +3 | 4 | print('Hello world') | = help: Remove unnecessary coding comment diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP010.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP010.py.snap index 3b081afd9d87e..89d50cf2f49f8 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP010.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP010.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP010.py:1:1: UP010 [*] Unnecessary `__future__` imports `generators`, `nested_scopes` for target Python version | @@ -98,7 +97,7 @@ UP010.py:6:1: UP010 [*] Unnecessary `__future__` import `generators` for target 5 | from __future__ import print_function, generator_stop 6 | from __future__ import invalid_module, generators | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 -7 | +7 | 8 | if True: | = help: Remove unnecessary `__future__` import @@ -137,7 +136,7 @@ UP010.py:10:5: UP010 [*] Unnecessary `__future__` import `generators` for target 9 | from __future__ import generator_stop 10 | from __future__ import generators | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 -11 | +11 | 12 | if True: | = help: Remove unnecessary `__future__` import diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP013.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP013.py.snap index 0e03e843a1251..09bb75d3d812b 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP013.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP013.py.snap @@ -6,7 +6,7 @@ UP013.py:5:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class sy 4 | # dict literal 5 | MyType = TypedDict("MyType", {"a": int, "b": str}) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 -6 | +6 | 7 | # dict call | = help: Convert `MyType` to class syntax @@ -28,7 +28,7 @@ UP013.py:8:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class sy 7 | # dict call 8 | MyType = TypedDict("MyType", dict(a=int, b=str)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 - 9 | + 9 | 10 | # kwargs | = help: Convert `MyType` to class syntax @@ -50,7 +50,7 @@ UP013.py:11:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s 10 | # kwargs 11 | MyType = TypedDict("MyType", a=int, b=str) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 -12 | +12 | 13 | # Empty TypedDict | = help: Convert `MyType` to class syntax @@ -72,7 +72,7 @@ UP013.py:14:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s 13 | # Empty TypedDict 14 | MyType = TypedDict("MyType") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 -15 | +15 | 16 | # Literal values | = help: Convert `MyType` to class syntax @@ -114,7 +114,7 @@ UP013.py:18:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s 17 | MyType = TypedDict("MyType", {"a": "hello"}) 18 | MyType = TypedDict("MyType", a="hello") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 -19 | +19 | 20 | # NotRequired | = help: Convert `MyType` to class syntax @@ -135,7 +135,7 @@ UP013.py:21:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s 20 | # NotRequired 21 | MyType = TypedDict("MyType", {"a": NotRequired[dict]}) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 -22 | +22 | 23 | # total | = help: Convert `MyType` to class syntax @@ -156,7 +156,7 @@ UP013.py:24:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s 23 | # total 24 | MyType = TypedDict("MyType", {"x": int, "y": int}, total=False) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 -25 | +25 | 26 | # using Literal type | = help: Convert `MyType` to class syntax @@ -178,7 +178,7 @@ UP013.py:27:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s 26 | # using Literal type 27 | MyType = TypedDict("MyType", {"key": Literal["value"]}) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 -28 | +28 | 29 | # using namespace TypedDict | = help: Convert `MyType` to class syntax @@ -199,7 +199,7 @@ UP013.py:30:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s 29 | # using namespace TypedDict 30 | MyType = typing.TypedDict("MyType", {"key": int}) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 -31 | +31 | 32 | # invalid identifiers (OK) | = help: Convert `MyType` to class syntax @@ -220,7 +220,7 @@ UP013.py:40:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s 39 | # Empty dict literal 40 | MyType = TypedDict("MyType", {}) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 -41 | +41 | 42 | # Empty dict call | = help: Convert `MyType` to class syntax @@ -241,7 +241,7 @@ UP013.py:43:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s 42 | # Empty dict call 43 | MyType = TypedDict("MyType", dict()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 -44 | +44 | 45 | # Unsafe fix if comments are present | = help: Convert `MyType` to class syntax diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP014.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP014.py.snap index 9a049ab22ac7c..24aec45ab885e 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP014.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP014.py.snap @@ -6,7 +6,7 @@ UP014.py:5:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class s 4 | # with complex annotations 5 | MyType = NamedTuple("MyType", [("a", int), ("b", tuple[str, ...])]) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014 -6 | +6 | 7 | # with namespace | = help: Convert `MyType` to class syntax @@ -28,7 +28,7 @@ UP014.py:8:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class s 7 | # with namespace 8 | MyType = typing.NamedTuple("MyType", [("a", int), ("b", str)]) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014 - 9 | + 9 | 10 | # invalid identifiers (OK) | = help: Convert `MyType` to class syntax @@ -50,7 +50,7 @@ UP014.py:14:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class 13 | # no fields 14 | MyType = typing.NamedTuple("MyType") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014 -15 | +15 | 16 | # empty fields | = help: Convert `MyType` to class syntax @@ -71,7 +71,7 @@ UP014.py:17:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class 16 | # empty fields 17 | MyType = typing.NamedTuple("MyType", []) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014 -18 | +18 | 19 | # keywords | = help: Convert `MyType` to class syntax @@ -92,7 +92,7 @@ UP014.py:20:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class 19 | # keywords 20 | MyType = typing.NamedTuple("MyType", a=int, b=tuple[str, ...]) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014 -21 | +21 | 22 | # unfixable | = help: Convert `MyType` to class syntax diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP015.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP015.py.snap index 40e6e2a2b2a83..57b1ab13c81c8 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP015.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP015.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP015.py:1:1: UP015 [*] Unnecessary open mode parameters | @@ -166,7 +165,7 @@ UP015.py:9:1: UP015 [*] Unnecessary open mode parameters, use "w" 8 | open("f", "wt") 9 | open("f", "tw") | ^^^^^^^^^^^^^^^ UP015 -10 | +10 | 11 | with open("foo", "U") as f: | = help: Replace with "w" @@ -184,7 +183,7 @@ UP015.py:9:1: UP015 [*] Unnecessary open mode parameters, use "w" UP015.py:11:6: UP015 [*] Unnecessary open mode parameters | 9 | open("f", "tw") -10 | +10 | 11 | with open("foo", "U") as f: | ^^^^^^^^^^^^^^^^ UP015 12 | pass @@ -351,7 +350,7 @@ UP015.py:25:6: UP015 [*] Unnecessary open mode parameters, use "w" UP015.py:28:1: UP015 [*] Unnecessary open mode parameters | 26 | pass -27 | +27 | 28 | open(f("a", "b", "c"), "U") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 29 | open(f("a", "b", "c"), "Ub") @@ -373,7 +372,7 @@ UP015.py:29:1: UP015 [*] Unnecessary open mode parameters, use "rb" 28 | open(f("a", "b", "c"), "U") 29 | open(f("a", "b", "c"), "Ub") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -30 | +30 | 31 | with open(f("a", "b", "c"), "U") as f: | = help: Replace with "rb" @@ -391,7 +390,7 @@ UP015.py:29:1: UP015 [*] Unnecessary open mode parameters, use "rb" UP015.py:31:6: UP015 [*] Unnecessary open mode parameters | 29 | open(f("a", "b", "c"), "Ub") -30 | +30 | 31 | with open(f("a", "b", "c"), "U") as f: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 32 | pass @@ -432,7 +431,7 @@ UP015.py:33:6: UP015 [*] Unnecessary open mode parameters, use "rb" UP015.py:36:6: UP015 [*] Unnecessary open mode parameters | 34 | pass -35 | +35 | 36 | with open("foo", "U") as fa, open("bar", "U") as fb: | ^^^^^^^^^^^^^^^^ UP015 37 | pass @@ -453,7 +452,7 @@ UP015.py:36:6: UP015 [*] Unnecessary open mode parameters UP015.py:36:30: UP015 [*] Unnecessary open mode parameters | 34 | pass -35 | +35 | 36 | with open("foo", "U") as fa, open("bar", "U") as fb: | ^^^^^^^^^^^^^^^^ UP015 37 | pass @@ -514,7 +513,7 @@ UP015.py:38:31: UP015 [*] Unnecessary open mode parameters, use "rb" UP015.py:41:1: UP015 [*] Unnecessary open mode parameters | 39 | pass -40 | +40 | 41 | open("foo", mode="U") | ^^^^^^^^^^^^^^^^^^^^^ UP015 42 | open(name="foo", mode="U") @@ -557,7 +556,7 @@ UP015.py:43:1: UP015 [*] Unnecessary open mode parameters 42 | open(name="foo", mode="U") 43 | open(mode="U", name="foo") | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -44 | +44 | 45 | with open("foo", mode="U") as f: | = help: Remove open mode parameters @@ -575,7 +574,7 @@ UP015.py:43:1: UP015 [*] Unnecessary open mode parameters UP015.py:45:6: UP015 [*] Unnecessary open mode parameters | 43 | open(mode="U", name="foo") -44 | +44 | 45 | with open("foo", mode="U") as f: | ^^^^^^^^^^^^^^^^^^^^^ UP015 46 | pass @@ -637,7 +636,7 @@ UP015.py:49:6: UP015 [*] Unnecessary open mode parameters UP015.py:52:1: UP015 [*] Unnecessary open mode parameters, use "rb" | 50 | pass -51 | +51 | 52 | open("foo", mode="Ub") | ^^^^^^^^^^^^^^^^^^^^^^ UP015 53 | open(name="foo", mode="Ub") @@ -680,7 +679,7 @@ UP015.py:54:1: UP015 [*] Unnecessary open mode parameters, use "rb" 53 | open(name="foo", mode="Ub") 54 | open(mode="Ub", name="foo") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -55 | +55 | 56 | with open("foo", mode="Ub") as f: | = help: Replace with "rb" @@ -698,7 +697,7 @@ UP015.py:54:1: UP015 [*] Unnecessary open mode parameters, use "rb" UP015.py:56:6: UP015 [*] Unnecessary open mode parameters, use "rb" | 54 | open(mode="Ub", name="foo") -55 | +55 | 56 | with open("foo", mode="Ub") as f: | ^^^^^^^^^^^^^^^^^^^^^^ UP015 57 | pass @@ -760,7 +759,7 @@ UP015.py:60:6: UP015 [*] Unnecessary open mode parameters, use "rb" UP015.py:63:1: UP015 [*] Unnecessary open mode parameters | 61 | pass -62 | +62 | 63 | open(file="foo", mode='U', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 64 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') @@ -824,7 +823,7 @@ UP015.py:66:1: UP015 [*] Unnecessary open mode parameters 65 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) 66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -67 | +67 | 68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) | = help: Remove open mode parameters @@ -842,7 +841,7 @@ UP015.py:66:1: UP015 [*] Unnecessary open mode parameters UP015.py:68:1: UP015 [*] Unnecessary open mode parameters, use "rb" | 66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -67 | +67 | 68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 69 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') @@ -906,7 +905,7 @@ UP015.py:71:1: UP015 [*] Unnecessary open mode parameters, use "rb" 70 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) 71 | open(mode='Ub', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -72 | +72 | 73 | import aiofiles | = help: Replace with "rb" @@ -924,7 +923,7 @@ UP015.py:71:1: UP015 [*] Unnecessary open mode parameters, use "rb" UP015.py:75:1: UP015 [*] Unnecessary open mode parameters | 73 | import aiofiles -74 | +74 | 75 | aiofiles.open("foo", "U") | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 76 | aiofiles.open("foo", "r") @@ -967,7 +966,7 @@ UP015.py:77:1: UP015 [*] Unnecessary open mode parameters 76 | aiofiles.open("foo", "r") 77 | aiofiles.open("foo", mode="r") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -78 | +78 | 79 | open("foo", "r+") | = help: Remove open mode parameters diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018.py.snap index c6a6796bea94a..1bf6316ea1798 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP018.py:37:1: UP018 [*] Unnecessary `str` call (rewrite as a literal) | @@ -285,7 +284,7 @@ UP018.py:52:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal) 51 | bool(True) 52 | bool(False) | ^^^^^^^^^^^ UP018 -53 | +53 | 54 | # These become a literal but retain parentheses | = help: Replace with boolean literal @@ -305,7 +304,7 @@ UP018.py:55:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) 54 | # These become a literal but retain parentheses 55 | int(1).denominator | ^^^^^^ UP018 -56 | +56 | 57 | # These too are literals in spirit | = help: Replace with integer literal diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP020.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP020.py.snap index ed65106f25736..314d5aa499460 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP020.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP020.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP020.py:3:6: UP020 [*] Use builtin `open` | 1 | import io -2 | +2 | 3 | with io.open("f.txt", mode="r", buffering=-1, **kwargs) as f: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP020 4 | print(f.read()) @@ -24,7 +23,7 @@ UP020.py:3:6: UP020 [*] Use builtin `open` UP020.py:8:6: UP020 [*] Use builtin `open` | 6 | from io import open -7 | +7 | 8 | with open("f.txt") as f: | ^^^^^^^^^^^^^ UP020 9 | print(f.read()) diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP021.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP021.py.snap index 70eb08d6aed55..9d7e2095ad06b 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP021.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP021.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP021.py:5:25: UP021 [*] `universal_newlines` is deprecated, use `text` | @@ -48,7 +47,7 @@ UP021.py:7:14: UP021 [*] `universal_newlines` is deprecated, use `text` 6 | subprocess.run(["foo"], universal_newlines=True, text=True) 7 | run(["foo"], universal_newlines=True, check=False) | ^^^^^^^^^^^^^^^^^^ UP021 -8 | +8 | 9 | # OK | = help: Replace with `text` keyword argument diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP022.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP022.py.snap index 670cbbaee6545..990936ee28c3b 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP022.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP022.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP022.py:4:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` | 2 | import subprocess -3 | +3 | 4 | output = run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP022 -5 | +5 | 6 | output = subprocess.run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | = help: Replace with `capture_output` keyword argument @@ -26,10 +25,10 @@ UP022.py:4:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stde UP022.py:6:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` | 4 | output = run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) -5 | +5 | 6 | output = subprocess.run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP022 -7 | +7 | 8 | output = subprocess.run(stdout=subprocess.PIPE, args=["foo"], stderr=subprocess.PIPE) | = help: Replace with `capture_output` keyword argument @@ -47,10 +46,10 @@ UP022.py:6:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stde UP022.py:8:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` | 6 | output = subprocess.run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - 7 | + 7 | 8 | output = subprocess.run(stdout=subprocess.PIPE, args=["foo"], stderr=subprocess.PIPE) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP022 - 9 | + 9 | 10 | output = subprocess.run( | = help: Replace with `capture_output` keyword argument @@ -68,13 +67,13 @@ UP022.py:8:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stde UP022.py:10:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` | 8 | output = subprocess.run(stdout=subprocess.PIPE, args=["foo"], stderr=subprocess.PIPE) - 9 | + 9 | 10 | output = subprocess.run( | __________^ 11 | | ["foo"], stdout=subprocess.PIPE, check=True, stderr=subprocess.PIPE 12 | | ) | |_^ UP022 -13 | +13 | 14 | output = subprocess.run( | = help: Replace with `capture_output` keyword argument @@ -92,13 +91,13 @@ UP022.py:10:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `std UP022.py:14:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` | 12 | ) -13 | +13 | 14 | output = subprocess.run( | __________^ 15 | | ["foo"], stderr=subprocess.PIPE, check=True, stdout=subprocess.PIPE 16 | | ) | |_^ UP022 -17 | +17 | 18 | output = subprocess.run( | = help: Replace with `capture_output` keyword argument @@ -116,7 +115,7 @@ UP022.py:14:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `std UP022.py:18:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` | 16 | ) -17 | +17 | 18 | output = subprocess.run( | __________^ 19 | | ["foo"], @@ -128,7 +127,7 @@ UP022.py:18:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `std 25 | | close_fds=True, 26 | | ) | |_^ UP022 -27 | +27 | 28 | if output: | = help: Replace with `capture_output` keyword argument @@ -158,7 +157,7 @@ UP022.py:29:14: UP022 [*] Prefer `capture_output` over sending `stdout` and `std 35 | | encoding="utf-8", 36 | | ) | |_____^ UP022 -37 | +37 | 38 | output = subprocess.run( | = help: Replace with `capture_output` keyword argument @@ -178,13 +177,13 @@ UP022.py:29:14: UP022 [*] Prefer `capture_output` over sending `stdout` and `std UP022.py:38:10: UP022 Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` | 36 | ) -37 | +37 | 38 | output = subprocess.run( | __________^ 39 | | ["foo"], stdout=subprocess.PIPE, capture_output=True, stderr=subprocess.PIPE 40 | | ) | |_^ UP022 -41 | +41 | 42 | output = subprocess.run( | = help: Replace with `capture_output` keyword argument @@ -192,13 +191,13 @@ UP022.py:38:10: UP022 Prefer `capture_output` over sending `stdout` and `stderr` UP022.py:42:10: UP022 Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` | 40 | ) -41 | +41 | 42 | output = subprocess.run( | __________^ 43 | | ["foo"], stdout=subprocess.PIPE, capture_output=False, stderr=subprocess.PIPE 44 | | ) | |_^ UP022 -45 | +45 | 46 | output = subprocess.run( | = help: Replace with `capture_output` keyword argument @@ -206,13 +205,13 @@ UP022.py:42:10: UP022 Prefer `capture_output` over sending `stdout` and `stderr` UP022.py:46:10: UP022 Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` | 44 | ) -45 | +45 | 46 | output = subprocess.run( | __________^ 47 | | ["foo"], capture_output=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE 48 | | ) | |_^ UP022 -49 | +49 | 50 | # OK | = help: Replace with `capture_output` keyword argument diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP023.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP023.py.snap index 319ac218504d1..33e1699fe35b1 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP023.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP023.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP023.py:2:1: UP023 [*] `cElementTree` is deprecated, use `ElementTree` | @@ -25,7 +24,7 @@ UP023.py:3:8: UP023 [*] `cElementTree` is deprecated, use `ElementTree` 2 | from xml.etree.cElementTree import XML, Element, SubElement 3 | import xml.etree.cElementTree as ET | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 -4 | +4 | 5 | # Weird spacing should not cause issues. | = help: Replace with `ElementTree` @@ -64,7 +63,7 @@ UP023.py:7:11: UP023 [*] `cElementTree` is deprecated, use `ElementTree` 6 | from xml.etree.cElementTree import XML 7 | import xml.etree.cElementTree as ET | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 -8 | +8 | 9 | # Multi line imports should also work fine. | = help: Replace with `ElementTree` @@ -129,7 +128,7 @@ UP023.py:17:27: UP023 [*] `cElementTree` is deprecated, use `ElementTree` 16 | import xml.etree.cElementTree as ET 17 | from xml.etree import cElementTree as CET | ^^^^^^^^^^^^^^^^^^^ UP023 -18 | +18 | 19 | from xml.etree import cElementTree as ET | = help: Replace with `ElementTree` @@ -147,10 +146,10 @@ UP023.py:17:27: UP023 [*] `cElementTree` is deprecated, use `ElementTree` UP023.py:19:23: UP023 [*] `cElementTree` is deprecated, use `ElementTree` | 17 | from xml.etree import cElementTree as CET -18 | +18 | 19 | from xml.etree import cElementTree as ET | ^^^^^^^^^^^^^^^^^^ UP023 -20 | +20 | 21 | import contextlib, xml.etree.cElementTree as ET | = help: Replace with `ElementTree` @@ -168,10 +167,10 @@ UP023.py:19:23: UP023 [*] `cElementTree` is deprecated, use `ElementTree` UP023.py:21:20: UP023 [*] `cElementTree` is deprecated, use `ElementTree` | 19 | from xml.etree import cElementTree as ET -20 | +20 | 21 | import contextlib, xml.etree.cElementTree as ET | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 -22 | +22 | 23 | # This should fix the second, but not the first invocation. | = help: Replace with `ElementTree` @@ -191,7 +190,7 @@ UP023.py:24:32: UP023 [*] `cElementTree` is deprecated, use `ElementTree` 23 | # This should fix the second, but not the first invocation. 24 | import xml.etree.cElementTree, xml.etree.cElementTree as ET | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 -25 | +25 | 26 | # The below items should NOT be changed. | = help: Replace with `ElementTree` diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_2.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_2.py.snap index 31aebee5a08bd..b6e358f62f226 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_2.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_2.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP024_2.py:10:7: UP024 [*] Replace aliased errors with `OSError` | @@ -49,7 +48,7 @@ UP024_2.py:12:7: UP024 [*] Replace aliased errors with `OSError` 11 | raise mmap.error 12 | raise select.error | ^^^^^^^^^^^^ UP024 -13 | +13 | 14 | raise socket.error() | = help: Replace `select.error` with builtin `OSError` @@ -67,7 +66,7 @@ UP024_2.py:12:7: UP024 [*] Replace aliased errors with `OSError` UP024_2.py:14:7: UP024 [*] Replace aliased errors with `OSError` | 12 | raise select.error -13 | +13 | 14 | raise socket.error() | ^^^^^^^^^^^^ UP024 15 | raise mmap.error(1) @@ -110,7 +109,7 @@ UP024_2.py:16:7: UP024 [*] Replace aliased errors with `OSError` 15 | raise mmap.error(1) 16 | raise select.error(1, 2) | ^^^^^^^^^^^^ UP024 -17 | +17 | 18 | raise socket.error( | = help: Replace `select.error` with builtin `OSError` @@ -128,7 +127,7 @@ UP024_2.py:16:7: UP024 [*] Replace aliased errors with `OSError` UP024_2.py:18:7: UP024 [*] Replace aliased errors with `OSError` | 16 | raise select.error(1, 2) -17 | +17 | 18 | raise socket.error( | ^^^^^^^^^^^^ UP024 19 | 1, @@ -151,7 +150,7 @@ UP024_2.py:25:7: UP024 [*] Replace aliased errors with `OSError` 24 | from mmap import error 25 | raise error | ^^^^^ UP024 -26 | +26 | 27 | from socket import error | = help: Replace `error` with builtin `OSError` @@ -171,7 +170,7 @@ UP024_2.py:28:7: UP024 [*] Replace aliased errors with `OSError` 27 | from socket import error 28 | raise error(1) | ^^^^^ UP024 -29 | +29 | 30 | from select import error | = help: Replace `error` with builtin `OSError` @@ -191,7 +190,7 @@ UP024_2.py:31:7: UP024 [*] Replace aliased errors with `OSError` 30 | from select import error 31 | raise error(1, 2) | ^^^^^ UP024 -32 | +32 | 33 | # Testing the names | = help: Replace `error` with builtin `OSError` @@ -252,7 +251,7 @@ UP024_2.py:36:7: UP024 [*] Replace aliased errors with `OSError` 35 | raise IOError 36 | raise WindowsError | ^^^^^^^^^^^^ UP024 -37 | +37 | 38 | raise EnvironmentError() | = help: Replace `WindowsError` with builtin `OSError` @@ -270,7 +269,7 @@ UP024_2.py:36:7: UP024 [*] Replace aliased errors with `OSError` UP024_2.py:38:7: UP024 [*] Replace aliased errors with `OSError` | 36 | raise WindowsError -37 | +37 | 38 | raise EnvironmentError() | ^^^^^^^^^^^^^^^^ UP024 39 | raise IOError(1) @@ -313,7 +312,7 @@ UP024_2.py:40:7: UP024 [*] Replace aliased errors with `OSError` 39 | raise IOError(1) 40 | raise WindowsError(1, 2) | ^^^^^^^^^^^^ UP024 -41 | +41 | 42 | raise EnvironmentError( | = help: Replace `WindowsError` with builtin `OSError` @@ -331,7 +330,7 @@ UP024_2.py:40:7: UP024 [*] Replace aliased errors with `OSError` UP024_2.py:42:7: UP024 [*] Replace aliased errors with `OSError` | 40 | raise WindowsError(1, 2) -41 | +41 | 42 | raise EnvironmentError( | ^^^^^^^^^^^^^^^^ UP024 43 | 1, @@ -352,7 +351,7 @@ UP024_2.py:42:7: UP024 [*] Replace aliased errors with `OSError` UP024_2.py:48:7: UP024 [*] Replace aliased errors with `OSError` | 46 | ) -47 | +47 | 48 | raise WindowsError | ^^^^^^^^^^^^ UP024 49 | raise EnvironmentError(1) diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP025.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP025.py.snap index 92a7f3e261f7e..916977bfed2f4 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP025.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP025.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP025.py:1:1: UP025 [*] Remove unicode literals from strings | 1 | u"Hello" | ^^^^^^^^ UP025 -2 | +2 | 3 | x = u"Hello" # UP025 | = help: Remove unicode prefix @@ -21,10 +20,10 @@ UP025.py:1:1: UP025 [*] Remove unicode literals from strings UP025.py:3:5: UP025 [*] Remove unicode literals from strings | 1 | u"Hello" -2 | +2 | 3 | x = u"Hello" # UP025 | ^^^^^^^^ UP025 -4 | +4 | 5 | u'world' # UP025 | = help: Remove unicode prefix @@ -41,10 +40,10 @@ UP025.py:3:5: UP025 [*] Remove unicode literals from strings UP025.py:5:1: UP025 [*] Remove unicode literals from strings | 3 | x = u"Hello" # UP025 -4 | +4 | 5 | u'world' # UP025 | ^^^^^^^^ UP025 -6 | +6 | 7 | print(u"Hello") # UP025 | = help: Remove unicode prefix @@ -62,10 +61,10 @@ UP025.py:5:1: UP025 [*] Remove unicode literals from strings UP025.py:7:7: UP025 [*] Remove unicode literals from strings | 5 | u'world' # UP025 -6 | +6 | 7 | print(u"Hello") # UP025 | ^^^^^^^^ UP025 -8 | +8 | 9 | print(u'world') # UP025 | = help: Remove unicode prefix @@ -83,10 +82,10 @@ UP025.py:7:7: UP025 [*] Remove unicode literals from strings UP025.py:9:7: UP025 [*] Remove unicode literals from strings | 7 | print(u"Hello") # UP025 - 8 | + 8 | 9 | print(u'world') # UP025 | ^^^^^^^^ UP025 -10 | +10 | 11 | import foo | = help: Remove unicode prefix @@ -104,10 +103,10 @@ UP025.py:9:7: UP025 [*] Remove unicode literals from strings UP025.py:13:5: UP025 [*] Remove unicode literals from strings | 11 | import foo -12 | +12 | 13 | foo(u"Hello", U"world", a=u"Hello", b=u"world") # UP025 | ^^^^^^^^ UP025 -14 | +14 | 15 | # Retain quotes when fixing. | = help: Remove unicode prefix @@ -125,10 +124,10 @@ UP025.py:13:5: UP025 [*] Remove unicode literals from strings UP025.py:13:15: UP025 [*] Remove unicode literals from strings | 11 | import foo -12 | +12 | 13 | foo(u"Hello", U"world", a=u"Hello", b=u"world") # UP025 | ^^^^^^^^ UP025 -14 | +14 | 15 | # Retain quotes when fixing. | = help: Remove unicode prefix @@ -146,10 +145,10 @@ UP025.py:13:15: UP025 [*] Remove unicode literals from strings UP025.py:13:27: UP025 [*] Remove unicode literals from strings | 11 | import foo -12 | +12 | 13 | foo(u"Hello", U"world", a=u"Hello", b=u"world") # UP025 | ^^^^^^^^ UP025 -14 | +14 | 15 | # Retain quotes when fixing. | = help: Remove unicode prefix @@ -167,10 +166,10 @@ UP025.py:13:27: UP025 [*] Remove unicode literals from strings UP025.py:13:39: UP025 [*] Remove unicode literals from strings | 11 | import foo -12 | +12 | 13 | foo(u"Hello", U"world", a=u"Hello", b=u"world") # UP025 | ^^^^^^^^ UP025 -14 | +14 | 15 | # Retain quotes when fixing. | = help: Remove unicode prefix @@ -252,7 +251,7 @@ UP025.py:19:5: UP025 [*] Remove unicode literals from strings 18 | x = u'''hello''' # UP025 19 | x = u'Hello "World"' # UP025 | ^^^^^^^^^^^^^^^^ UP025 -20 | +20 | 21 | u = "Hello" # OK | = help: Remove unicode prefix @@ -270,7 +269,7 @@ UP025.py:19:5: UP025 [*] Remove unicode literals from strings UP025.py:27:7: UP025 [*] Remove unicode literals from strings | 25 | return"Hello" # OK -26 | +26 | 27 | f"foo"u"bar" # OK | ^^^^^^ UP025 28 | f"foo" u"bar" # OK diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_2.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_2.py.snap index a852bdc242288..2789248a3c1a5 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_2.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_2.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP032_2.py:2:1: UP032 [*] Use f-string instead of `format` call | @@ -45,7 +44,7 @@ UP032_2.py:4:1: UP032 [*] Use f-string instead of `format` call 3 | "{0.real}".format(1) 4 | "{a.real}".format(a=1) | ^^^^^^^^^^^^^^^^^^^^^^ UP032 -5 | +5 | 6 | "{.real}".format(1.0) | = help: Convert to f-string @@ -63,7 +62,7 @@ UP032_2.py:4:1: UP032 [*] Use f-string instead of `format` call UP032_2.py:6:1: UP032 [*] Use f-string instead of `format` call | 4 | "{a.real}".format(a=1) -5 | +5 | 6 | "{.real}".format(1.0) | ^^^^^^^^^^^^^^^^^^^^^ UP032 7 | "{0.real}".format(1.0) @@ -106,7 +105,7 @@ UP032_2.py:8:1: UP032 [*] Use f-string instead of `format` call 7 | "{0.real}".format(1.0) 8 | "{a.real}".format(a=1.0) | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 - 9 | + 9 | 10 | "{.real}".format(1j) | = help: Convert to f-string @@ -124,7 +123,7 @@ UP032_2.py:8:1: UP032 [*] Use f-string instead of `format` call UP032_2.py:10:1: UP032 [*] Use f-string instead of `format` call | 8 | "{a.real}".format(a=1.0) - 9 | + 9 | 10 | "{.real}".format(1j) | ^^^^^^^^^^^^^^^^^^^^ UP032 11 | "{0.real}".format(1j) @@ -167,7 +166,7 @@ UP032_2.py:12:1: UP032 [*] Use f-string instead of `format` call 11 | "{0.real}".format(1j) 12 | "{a.real}".format(a=1j) | ^^^^^^^^^^^^^^^^^^^^^^^ UP032 -13 | +13 | 14 | "{.real}".format(0b01) | = help: Convert to f-string @@ -185,7 +184,7 @@ UP032_2.py:12:1: UP032 [*] Use f-string instead of `format` call UP032_2.py:14:1: UP032 [*] Use f-string instead of `format` call | 12 | "{a.real}".format(a=1j) -13 | +13 | 14 | "{.real}".format(0b01) | ^^^^^^^^^^^^^^^^^^^^^^ UP032 15 | "{0.real}".format(0b01) @@ -228,7 +227,7 @@ UP032_2.py:16:1: UP032 [*] Use f-string instead of `format` call 15 | "{0.real}".format(0b01) 16 | "{a.real}".format(a=0b01) | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -17 | +17 | 18 | "{}".format(1 + 2) | = help: Convert to f-string @@ -246,7 +245,7 @@ UP032_2.py:16:1: UP032 [*] Use f-string instead of `format` call UP032_2.py:18:1: UP032 [*] Use f-string instead of `format` call | 16 | "{a.real}".format(a=0b01) -17 | +17 | 18 | "{}".format(1 + 2) | ^^^^^^^^^^^^^^^^^^ UP032 19 | "{}".format([1, 2]) @@ -331,7 +330,7 @@ UP032_2.py:22:1: UP032 [*] Use f-string instead of `format` call 21 | "{}".format({1: 2, 3: 4}) 22 | "{}".format((i for i in range(2))) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -23 | +23 | 24 | "{.real}".format(1 + 2) | = help: Convert to f-string @@ -349,7 +348,7 @@ UP032_2.py:22:1: UP032 [*] Use f-string instead of `format` call UP032_2.py:24:1: UP032 [*] Use f-string instead of `format` call | 22 | "{}".format((i for i in range(2))) -23 | +23 | 24 | "{.real}".format(1 + 2) | ^^^^^^^^^^^^^^^^^^^^^^^ UP032 25 | "{.real}".format([1, 2]) diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP034.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP034.py.snap index 98b05d49ac067..4c93c84778067 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP034.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP034.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP034.py:2:7: UP034 [*] Avoid extraneous parentheses | 1 | # UP034 2 | print(("foo")) | ^^^^^^^ UP034 -3 | +3 | 4 | # UP034 | = help: Remove extraneous parentheses @@ -25,7 +24,7 @@ UP034.py:5:7: UP034 [*] Avoid extraneous parentheses 4 | # UP034 5 | print(("hell((goodybe))o")) | ^^^^^^^^^^^^^^^^^^^^ UP034 -6 | +6 | 7 | # UP034 | = help: Remove extraneous parentheses @@ -45,7 +44,7 @@ UP034.py:8:7: UP034 [*] Avoid extraneous parentheses 7 | # UP034 8 | print((("foo"))) | ^^^^^^^^^ UP034 - 9 | + 9 | 10 | # UP034 | = help: Remove extraneous parentheses @@ -65,7 +64,7 @@ UP034.py:11:7: UP034 [*] Avoid extraneous parentheses 10 | # UP034 11 | print((((1)))) | ^^^^^^^ UP034 -12 | +12 | 13 | # UP034 | = help: Remove extraneous parentheses @@ -85,7 +84,7 @@ UP034.py:14:7: UP034 [*] Avoid extraneous parentheses 13 | # UP034 14 | print(("foo{}".format(1))) | ^^^^^^^^^^^^^^^^^^^ UP034 -15 | +15 | 16 | # UP034 | = help: Remove extraneous parentheses @@ -124,8 +123,7 @@ UP034.py:23:5: UP034 [*] Avoid extraneous parentheses | 21 | # UP034 22 | print( -23 | ( - | _____^ +23 | / ( 24 | | "foo" 25 | | ) | |_____^ UP034 @@ -152,7 +150,7 @@ UP034.py:30:13: UP034 [*] Avoid extraneous parentheses 29 | def f(): 30 | x = int(((yield 1))) | ^^^^^^^^^^^ UP034 -31 | +31 | 32 | # UP034 | = help: Remove extraneous parentheses @@ -192,7 +190,7 @@ UP034.py:39:7: UP034 [*] Avoid extraneous parentheses 38 | # UP034 39 | print((x for x in range(3))) | ^^^^^^^^^^^^^^^^^^^^^ UP034 -40 | +40 | 41 | # OK | = help: Remove extraneous parentheses diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_0.py.snap index 9c23af8835bc4..497f7bec514d3 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_0.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP036_0.py:3:4: UP036 [*] Version block is outdated for minimum Python version | 1 | import sys -2 | +2 | 3 | if sys.version_info < (3,0): | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 4 | print("py2") @@ -28,7 +27,7 @@ UP036_0.py:3:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:8:4: UP036 [*] Version block is outdated for minimum Python version | 6 | print("py3") - 7 | + 7 | 8 | if sys.version_info < (3,0): | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 9 | if True: @@ -55,7 +54,7 @@ UP036_0.py:8:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:16:4: UP036 [*] Version block is outdated for minimum Python version | 14 | print("py3") -15 | +15 | 16 | if sys.version_info < (3,0): print("PY2!") | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 17 | else: print("PY3!") @@ -99,7 +98,7 @@ UP036_0.py:20:8: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:25:4: UP036 [*] Version block is outdated for minimum Python version | 23 | print("PY3") -24 | +24 | 25 | if sys.version_info < (3,0): print(1 if True else 3) | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 26 | else: @@ -122,7 +121,7 @@ UP036_0.py:25:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:29:4: UP036 [*] Version block is outdated for minimum Python version | 27 | print("py3") -28 | +28 | 29 | if sys.version_info < (3,0): | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 30 | def f(): @@ -151,7 +150,7 @@ UP036_0.py:29:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:37:4: UP036 [*] Version block is outdated for minimum Python version | 35 | print("This the next") -36 | +36 | 37 | if sys.version_info > (3,0): | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 38 | print("py3") @@ -175,7 +174,7 @@ UP036_0.py:37:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:45:4: UP036 [*] Version block is outdated for minimum Python version | 43 | x = 1 -44 | +44 | 45 | if sys.version_info > (3,0): | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 46 | print("py3") @@ -199,7 +198,7 @@ UP036_0.py:45:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:53:4: UP036 [*] Version block is outdated for minimum Python version | 51 | x = 1 -52 | +52 | 53 | if sys.version_info > (3,0): print("py3") | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 54 | else: print("py2") @@ -220,7 +219,7 @@ UP036_0.py:53:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:56:4: UP036 [*] Version block is outdated for minimum Python version | 54 | else: print("py2") -55 | +55 | 56 | if sys.version_info > (3,): | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 57 | print("py3") @@ -267,7 +266,7 @@ UP036_0.py:62:8: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:67:4: UP036 [*] Version block is outdated for minimum Python version | 65 | print("py2") -66 | +66 | 67 | if sys.version_info < (3,): | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 68 | print("py2") @@ -317,7 +316,7 @@ UP036_0.py:73:8: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:86:8: UP036 [*] Version block is outdated for minimum Python version | 84 | pass -85 | +85 | 86 | if sys.version_info < (3,0): | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 87 | def f(py2): @@ -367,7 +366,7 @@ UP036_0.py:97:8: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:104:4: UP036 [*] Version block is outdated for minimum Python version | 102 | # comment -103 | +103 | 104 | if sys.version_info < (3,0): | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 105 | def f(): @@ -423,7 +422,7 @@ UP036_0.py:122:8: UP036 [*] Version block is outdated for minimum Python version 121 | if True: 122 | if sys.version_info > (3,): print(3) | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 -123 | +123 | 124 | if True: | = help: Remove outdated version block @@ -550,7 +549,7 @@ UP036_0.py:150:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:163:4: UP036 [*] Version block is outdated for minimum Python version | 161 | "this for some reason") -162 | +162 | 163 | if sys.version_info > (3, 0): expected_error = \ | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 164 | [] @@ -570,10 +569,10 @@ UP036_0.py:163:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:166:4: UP036 [*] Version block is outdated for minimum Python version | 164 | [] -165 | +165 | 166 | if sys.version_info > (3, 0): expected_error = [] | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -167 | +167 | 168 | if sys.version_info > (3, 0): \ | = help: Remove outdated version block @@ -591,7 +590,7 @@ UP036_0.py:166:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:168:4: UP036 [*] Version block is outdated for minimum Python version | 166 | if sys.version_info > (3, 0): expected_error = [] -167 | +167 | 168 | if sys.version_info > (3, 0): \ | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 169 | expected_error = [] @@ -633,7 +632,7 @@ UP036_0.py:176:8: UP036 [*] Version block is outdated for minimum Python version 175 | if True: 176 | if sys.version_info > (3, 0): expected_error = [] | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -177 | +177 | 178 | if True: | = help: Remove outdated version block @@ -669,7 +668,7 @@ UP036_0.py:179:8: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:182:4: UP036 [*] Version block is outdated for minimum Python version | 180 | expected_error = [] -181 | +181 | 182 | if sys.version_info < (3,13): | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 183 | print("py3") @@ -689,7 +688,7 @@ UP036_0.py:182:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:191:24: UP036 Version specifier is invalid | 189 | print("py3") -190 | +190 | 191 | if sys.version_info == 10000000: | ^^^^^^^^ UP036 192 | print("py3") @@ -698,7 +697,7 @@ UP036_0.py:191:24: UP036 Version specifier is invalid UP036_0.py:194:23: UP036 Version specifier is invalid | 192 | print("py3") -193 | +193 | 194 | if sys.version_info < (3,10000000): | ^^^^^^^^^^^^ UP036 195 | print("py3") @@ -707,7 +706,7 @@ UP036_0.py:194:23: UP036 Version specifier is invalid UP036_0.py:197:24: UP036 Version specifier is invalid | 195 | print("py3") -196 | +196 | 197 | if sys.version_info <= (3,10000000): | ^^^^^^^^^^^^ UP036 198 | print("py3") @@ -716,7 +715,7 @@ UP036_0.py:197:24: UP036 Version specifier is invalid UP036_0.py:203:4: UP036 [*] Version block is outdated for minimum Python version | 201 | print("py3") -202 | +202 | 203 | if sys.version_info >= (3,13): | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 204 | print("py3") @@ -757,7 +756,7 @@ UP036_0.py:207:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:210:4: UP036 [*] Version block is outdated for minimum Python version | 208 | print("py3") -209 | +209 | 210 | if sys.version_info[:3] >= (3,0): | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 211 | print("py3") @@ -778,7 +777,7 @@ UP036_0.py:210:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:219:4: UP036 [*] Version block is outdated for minimum Python version | 217 | print("py3") -218 | +218 | 219 | if sys.version_info > (3,0): | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 220 | f"this is\ @@ -808,7 +807,7 @@ UP036_0.py:219:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:229:4: UP036 [*] Version block is outdated for minimum Python version | 227 | allowed too" -228 | +228 | 229 | if sys.version_info[0] == 3: | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 230 | print("py3") @@ -829,7 +828,7 @@ UP036_0.py:229:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:232:4: UP036 [*] Version block is outdated for minimum Python version | 230 | print("py3") -231 | +231 | 232 | if sys.version_info[0] <= 3: | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 233 | print("py3") @@ -850,7 +849,7 @@ UP036_0.py:232:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:235:4: UP036 [*] Version block is outdated for minimum Python version | 233 | print("py3") -234 | +234 | 235 | if sys.version_info[0] < 3: | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 236 | print("py3") @@ -870,7 +869,7 @@ UP036_0.py:235:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:238:4: UP036 [*] Version block is outdated for minimum Python version | 236 | print("py3") -237 | +237 | 238 | if sys.version_info[0] >= 3: | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 239 | print("py3") @@ -891,7 +890,7 @@ UP036_0.py:238:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:241:4: UP036 [*] Version block is outdated for minimum Python version | 239 | print("py3") -240 | +240 | 241 | if sys.version_info[0] > 3: | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 242 | print("py3") @@ -911,7 +910,7 @@ UP036_0.py:241:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:244:4: UP036 [*] Version block is outdated for minimum Python version | 242 | print("py3") -243 | +243 | 244 | if sys.version_info[0] == 2: | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 245 | print("py3") @@ -931,7 +930,7 @@ UP036_0.py:244:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:247:4: UP036 [*] Version block is outdated for minimum Python version | 245 | print("py3") -246 | +246 | 247 | if sys.version_info[0] <= 2: | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 248 | print("py3") @@ -951,7 +950,7 @@ UP036_0.py:247:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:250:4: UP036 [*] Version block is outdated for minimum Python version | 248 | print("py3") -249 | +249 | 250 | if sys.version_info[0] < 2: | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 251 | print("py3") @@ -971,7 +970,7 @@ UP036_0.py:250:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:253:4: UP036 [*] Version block is outdated for minimum Python version | 251 | print("py3") -252 | +252 | 253 | if sys.version_info[0] >= 2: | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 254 | print("py3") @@ -992,7 +991,7 @@ UP036_0.py:253:4: UP036 [*] Version block is outdated for minimum Python version UP036_0.py:256:4: UP036 [*] Version block is outdated for minimum Python version | 254 | print("py3") -255 | +255 | 256 | if sys.version_info[0] > 2: | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 257 | print("py3") diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_1.py.snap index 9a7f623e2695b..a7619f082514b 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_1.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_1.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP036_1.py:3:4: UP036 [*] Version block is outdated for minimum Python version | 1 | import sys -2 | +2 | 3 | if sys.version_info == 2: | ^^^^^^^^^^^^^^^^^^^^^ UP036 4 | 2 @@ -28,7 +27,7 @@ UP036_1.py:3:4: UP036 [*] Version block is outdated for minimum Python version UP036_1.py:8:4: UP036 [*] Version block is outdated for minimum Python version | 6 | 3 - 7 | + 7 | 8 | if sys.version_info < (3,): | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 9 | 2 @@ -52,7 +51,7 @@ UP036_1.py:8:4: UP036 [*] Version block is outdated for minimum Python version UP036_1.py:13:4: UP036 [*] Version block is outdated for minimum Python version | 11 | 3 -12 | +12 | 13 | if sys.version_info < (3,0): | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 14 | 2 @@ -76,7 +75,7 @@ UP036_1.py:13:4: UP036 [*] Version block is outdated for minimum Python version UP036_1.py:18:4: UP036 [*] Version block is outdated for minimum Python version | 16 | 3 -17 | +17 | 18 | if sys.version_info == 3: | ^^^^^^^^^^^^^^^^^^^^^ UP036 19 | 3 @@ -100,7 +99,7 @@ UP036_1.py:18:4: UP036 [*] Version block is outdated for minimum Python version UP036_1.py:23:4: UP036 [*] Version block is outdated for minimum Python version | 21 | 2 -22 | +22 | 23 | if sys.version_info > (3,): | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 24 | 3 @@ -124,7 +123,7 @@ UP036_1.py:23:4: UP036 [*] Version block is outdated for minimum Python version UP036_1.py:28:4: UP036 [*] Version block is outdated for minimum Python version | 26 | 2 -27 | +27 | 28 | if sys.version_info >= (3,): | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 29 | 3 @@ -148,7 +147,7 @@ UP036_1.py:28:4: UP036 [*] Version block is outdated for minimum Python version UP036_1.py:35:4: UP036 [*] Version block is outdated for minimum Python version | 33 | from sys import version_info -34 | +34 | 35 | if version_info > (3,): | ^^^^^^^^^^^^^^^^^^^ UP036 36 | 3 diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_2.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_2.py.snap index 964c71c65d39d..b5d6a7e33a5e9 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_2.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_2.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP036_2.py:4:4: UP036 [*] Version block is outdated for minimum Python version | 2 | from sys import version_info -3 | +3 | 4 | if sys.version_info > (3, 5): | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 5 | 3+6 @@ -29,7 +28,7 @@ UP036_2.py:4:4: UP036 [*] Version block is outdated for minimum Python version UP036_2.py:9:4: UP036 [*] Version block is outdated for minimum Python version | 7 | 3-5 - 8 | + 8 | 9 | if version_info > (3, 5): | ^^^^^^^^^^^^^^^^^^^^^ UP036 10 | 3+6 @@ -53,7 +52,7 @@ UP036_2.py:9:4: UP036 [*] Version block is outdated for minimum Python version UP036_2.py:14:4: UP036 [*] Version block is outdated for minimum Python version | 12 | 3-5 -13 | +13 | 14 | if sys.version_info >= (3,6): | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 15 | 3+6 @@ -77,7 +76,7 @@ UP036_2.py:14:4: UP036 [*] Version block is outdated for minimum Python version UP036_2.py:19:4: UP036 [*] Version block is outdated for minimum Python version | 17 | 3-5 -18 | +18 | 19 | if version_info >= (3,6): | ^^^^^^^^^^^^^^^^^^^^^ UP036 20 | 3+6 @@ -101,7 +100,7 @@ UP036_2.py:19:4: UP036 [*] Version block is outdated for minimum Python version UP036_2.py:24:4: UP036 [*] Version block is outdated for minimum Python version | 22 | 3-5 -23 | +23 | 24 | if sys.version_info < (3,6): | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 25 | 3-5 @@ -125,7 +124,7 @@ UP036_2.py:24:4: UP036 [*] Version block is outdated for minimum Python version UP036_2.py:29:4: UP036 [*] Version block is outdated for minimum Python version | 27 | 3+6 -28 | +28 | 29 | if sys.version_info <= (3,5): | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 30 | 3-5 @@ -149,7 +148,7 @@ UP036_2.py:29:4: UP036 [*] Version block is outdated for minimum Python version UP036_2.py:34:4: UP036 [*] Version block is outdated for minimum Python version | 32 | 3+6 -33 | +33 | 34 | if sys.version_info <= (3, 5): | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 35 | 3-5 @@ -173,7 +172,7 @@ UP036_2.py:34:4: UP036 [*] Version block is outdated for minimum Python version UP036_2.py:39:4: UP036 [*] Version block is outdated for minimum Python version | 37 | 3+6 -38 | +38 | 39 | if sys.version_info >= (3, 5): | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 40 | pass @@ -194,7 +193,7 @@ UP036_2.py:39:4: UP036 [*] Version block is outdated for minimum Python version UP036_2.py:42:4: UP036 [*] Version block is outdated for minimum Python version | 40 | pass -41 | +41 | 42 | if sys.version_info < (3,0): | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 43 | pass @@ -234,7 +233,7 @@ UP036_2.py:46:8: UP036 [*] Version block is outdated for minimum Python version UP036_2.py:49:4: UP036 [*] Version block is outdated for minimum Python version | 47 | pass -48 | +48 | 49 | if sys.version_info < (3,0): | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 50 | pass @@ -257,7 +256,7 @@ UP036_2.py:49:4: UP036 [*] Version block is outdated for minimum Python version UP036_2.py:54:4: UP036 [*] Version block is outdated for minimum Python version | 52 | pass -53 | +53 | 54 | if sys.version_info > (3,): | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 55 | pass diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_3.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_3.py.snap index aea4432b416f1..8b68445648682 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_3.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_3.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP036_3.py:3:15: UP036 [*] Version block is outdated for minimum Python version | 1 | import sys -2 | +2 | 3 | if sys.version_info < (3,0): | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 4 | print("py2") diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_4.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_4.py.snap index 0d226c5168fdd..fb13811cfe183 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_4.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_4.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP036_4.py:4:8: UP036 [*] Version block is outdated for minimum Python version | @@ -88,7 +87,7 @@ UP036_4.py:24:10: UP036 [*] Version block is outdated for minimum Python version UP036_4.py:27:8: UP036 [*] Version block is outdated for minimum Python version | 25 | cmd = [sys.executable, "-m", "test.regrtest"] -26 | +26 | 27 | if sys.version_info < (3, 3): | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 28 | cmd = [sys.executable, "-m", "test.regrtest"] @@ -129,7 +128,7 @@ UP036_4.py:32:10: UP036 [*] Version block is outdated for minimum Python version UP036_4.py:37:8: UP036 [*] Version block is outdated for minimum Python version | 35 | cmd = [sys.executable, "-m", "test", "-j0"] -36 | +36 | 37 | if sys.version_info < (3, 3): | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 38 | cmd = [sys.executable, "-m", "test.regrtest"] @@ -153,7 +152,7 @@ UP036_4.py:37:8: UP036 [*] Version block is outdated for minimum Python version UP036_4.py:42:8: UP036 [*] Version block is outdated for minimum Python version | 40 | cmd = [sys.executable, "-m", "test", "-j0"] -41 | +41 | 42 | if sys.version_info < (3, 3): | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 43 | cmd = [sys.executable, "-m", "test.regrtest"] diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_5.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_5.py.snap index 62e5d77f2ef64..478ed274d9c10 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_5.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_5.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP036_5.py:3:4: UP036 [*] Version block is outdated for minimum Python version | 1 | import sys -2 | +2 | 3 | if sys.version_info < (3, 8): | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -4 | +4 | 5 | def a(): | = help: Remove outdated version block @@ -35,7 +34,7 @@ UP036_5.py:3:4: UP036 [*] Version block is outdated for minimum Python version UP036_5.py:18:4: UP036 [*] Version block is outdated for minimum Python version | 16 | import sys -17 | +17 | 18 | if sys.version_info < (3, 8): | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 19 | pass diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_0.py.snap index c323896def396..f2eeea618b2ae 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_0.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP037_0.py:18:14: UP037 [*] Remove quotes from type annotation | @@ -114,7 +113,7 @@ UP037_0.py:30:10: UP037 [*] Remove quotes from type annotation | 30 | x: Tuple["MyClass"] | ^^^^^^^^^ UP037 -31 | +31 | 32 | x: Callable[["MyClass"], None] | = help: Remove quotes @@ -132,7 +131,7 @@ UP037_0.py:30:10: UP037 [*] Remove quotes from type annotation UP037_0.py:32:14: UP037 [*] Remove quotes from type annotation | 30 | x: Tuple["MyClass"] -31 | +31 | 32 | x: Callable[["MyClass"], None] | ^^^^^^^^^ UP037 | @@ -206,7 +205,7 @@ UP037_0.py:47:14: UP037 [*] Remove quotes from type annotation | 47 | x: Annotated["str", "metadata"] | ^^^^^ UP037 -48 | +48 | 49 | x: Arg("str", "name") | = help: Remove quotes @@ -224,10 +223,10 @@ UP037_0.py:47:14: UP037 [*] Remove quotes from type annotation UP037_0.py:49:8: UP037 [*] Remove quotes from type annotation | 47 | x: Annotated["str", "metadata"] -48 | +48 | 49 | x: Arg("str", "name") | ^^^^^ UP037 -50 | +50 | 51 | x: DefaultArg("str", "name") | = help: Remove quotes @@ -245,10 +244,10 @@ UP037_0.py:49:8: UP037 [*] Remove quotes from type annotation UP037_0.py:51:15: UP037 [*] Remove quotes from type annotation | 49 | x: Arg("str", "name") -50 | +50 | 51 | x: DefaultArg("str", "name") | ^^^^^ UP037 -52 | +52 | 53 | x: NamedArg("str", "name") | = help: Remove quotes @@ -266,10 +265,10 @@ UP037_0.py:51:15: UP037 [*] Remove quotes from type annotation UP037_0.py:53:13: UP037 [*] Remove quotes from type annotation | 51 | x: DefaultArg("str", "name") -52 | +52 | 53 | x: NamedArg("str", "name") | ^^^^^ UP037 -54 | +54 | 55 | x: DefaultNamedArg("str", "name") | = help: Remove quotes @@ -287,10 +286,10 @@ UP037_0.py:53:13: UP037 [*] Remove quotes from type annotation UP037_0.py:55:20: UP037 [*] Remove quotes from type annotation | 53 | x: NamedArg("str", "name") -54 | +54 | 55 | x: DefaultNamedArg("str", "name") | ^^^^^ UP037 -56 | +56 | 57 | x: DefaultNamedArg("str", name="name") | = help: Remove quotes @@ -308,10 +307,10 @@ UP037_0.py:55:20: UP037 [*] Remove quotes from type annotation UP037_0.py:57:20: UP037 [*] Remove quotes from type annotation | 55 | x: DefaultNamedArg("str", "name") -56 | +56 | 57 | x: DefaultNamedArg("str", name="name") | ^^^^^ UP037 -58 | +58 | 59 | x: VarArg("str") | = help: Remove quotes @@ -329,10 +328,10 @@ UP037_0.py:57:20: UP037 [*] Remove quotes from type annotation UP037_0.py:59:11: UP037 [*] Remove quotes from type annotation | 57 | x: DefaultNamedArg("str", name="name") -58 | +58 | 59 | x: VarArg("str") | ^^^^^ UP037 -60 | +60 | 61 | x: List[List[List["MyClass"]]] | = help: Remove quotes @@ -350,10 +349,10 @@ UP037_0.py:59:11: UP037 [*] Remove quotes from type annotation UP037_0.py:61:19: UP037 [*] Remove quotes from type annotation | 59 | x: VarArg("str") -60 | +60 | 61 | x: List[List[List["MyClass"]]] | ^^^^^^^^^ UP037 -62 | +62 | 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) | = help: Remove quotes @@ -371,10 +370,10 @@ UP037_0.py:61:19: UP037 [*] Remove quotes from type annotation UP037_0.py:63:29: UP037 [*] Remove quotes from type annotation | 61 | x: List[List[List["MyClass"]]] -62 | +62 | 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) | ^^^^^ UP037 -64 | +64 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) | = help: Remove quotes @@ -392,10 +391,10 @@ UP037_0.py:63:29: UP037 [*] Remove quotes from type annotation UP037_0.py:63:45: UP037 [*] Remove quotes from type annotation | 61 | x: List[List[List["MyClass"]]] -62 | +62 | 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) | ^^^^^ UP037 -64 | +64 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) | = help: Remove quotes @@ -413,10 +412,10 @@ UP037_0.py:63:45: UP037 [*] Remove quotes from type annotation UP037_0.py:65:29: UP037 [*] Remove quotes from type annotation | 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) -64 | +64 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) | ^^^^^ UP037 -66 | +66 | 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) | = help: Remove quotes @@ -434,10 +433,10 @@ UP037_0.py:65:29: UP037 [*] Remove quotes from type annotation UP037_0.py:65:36: UP037 [*] Remove quotes from type annotation | 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) -64 | +64 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) | ^^^^^ UP037 -66 | +66 | 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) | = help: Remove quotes @@ -455,10 +454,10 @@ UP037_0.py:65:36: UP037 [*] Remove quotes from type annotation UP037_0.py:65:45: UP037 [*] Remove quotes from type annotation | 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) -64 | +64 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) | ^^^^^ UP037 -66 | +66 | 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) | = help: Remove quotes @@ -476,10 +475,10 @@ UP037_0.py:65:45: UP037 [*] Remove quotes from type annotation UP037_0.py:65:52: UP037 [*] Remove quotes from type annotation | 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) -64 | +64 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) | ^^^^^ UP037 -66 | +66 | 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) | = help: Remove quotes @@ -497,10 +496,10 @@ UP037_0.py:65:52: UP037 [*] Remove quotes from type annotation UP037_0.py:67:24: UP037 [*] Remove quotes from type annotation | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) -66 | +66 | 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) | ^^^ UP037 -68 | +68 | 69 | X: MyCallable("X") | = help: Remove quotes @@ -518,10 +517,10 @@ UP037_0.py:67:24: UP037 [*] Remove quotes from type annotation UP037_0.py:67:38: UP037 [*] Remove quotes from type annotation | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) -66 | +66 | 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) | ^^^^^ UP037 -68 | +68 | 69 | X: MyCallable("X") | = help: Remove quotes @@ -539,10 +538,10 @@ UP037_0.py:67:38: UP037 [*] Remove quotes from type annotation UP037_0.py:67:45: UP037 [*] Remove quotes from type annotation | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) -66 | +66 | 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) | ^^^^^ UP037 -68 | +68 | 69 | X: MyCallable("X") | = help: Remove quotes diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_2.pyi.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_2.pyi.snap index 1519dba9d7602..bffd9bbf7d236 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_2.pyi.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_2.pyi.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP037_2.pyi:3:14: UP037 [*] Remove quotes from type annotation | 1 | # https://github.com/astral-sh/ruff/issues/7102 -2 | +2 | 3 | def f(a: Foo['SingleLine # Comment']): ... | ^^^^^^^^^^^^^^^^^^^^^^^ UP037 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP038.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP038.py.snap index d29c4723fec2c..83bd5dbd1f050 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP038.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP038.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP038.py:1:1: UP038 [*] Use `X | Y` in `isinstance` call instead of `(X, Y)` | @@ -22,7 +21,7 @@ UP038.py:2:1: UP038 [*] Use `X | Y` in `issubclass` call instead of `(X, Y)` 1 | isinstance(1, (int, float)) # UP038 2 | issubclass("yes", (int, float, str)) # UP038 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP038 -3 | +3 | 4 | isinstance(1, int) # OK | = help: Convert to `X | Y` diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP040.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP040.py.snap index bb6346a05ce6b..0e68a81b0682d 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP040.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP040.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP040.py:5:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword | @@ -27,7 +26,7 @@ UP040.py:6:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of th 5 | x: typing.TypeAlias = int 6 | x: TypeAlias = int | ^^^^^^^^^^^^^^^^^^ UP040 -7 | +7 | 8 | # UP040 simple generic | = help: Use the `type` keyword @@ -48,7 +47,7 @@ UP040.py:10:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t 9 | T = typing.TypeVar["T"] 10 | x: typing.TypeAlias = list[T] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 -11 | +11 | 12 | # UP040 call style generic | = help: Use the `type` keyword @@ -69,7 +68,7 @@ UP040.py:14:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t 13 | T = typing.TypeVar("T") 14 | x: typing.TypeAlias = list[T] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 -15 | +15 | 16 | # UP040 bounded generic | = help: Use the `type` keyword @@ -90,7 +89,7 @@ UP040.py:18:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t 17 | T = typing.TypeVar("T", bound=int) 18 | x: typing.TypeAlias = list[T] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 -19 | +19 | 20 | # UP040 constrained generic | = help: Use the `type` keyword @@ -111,7 +110,7 @@ UP040.py:22:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t 21 | T = typing.TypeVar("T", int, str) 22 | x: typing.TypeAlias = list[T] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 -23 | +23 | 24 | # UP040 contravariant generic | = help: Use the `type` keyword @@ -132,7 +131,7 @@ UP040.py:26:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t 25 | T = typing.TypeVar("T", contravariant=True) 26 | x: typing.TypeAlias = list[T] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 -27 | +27 | 28 | # UP040 covariant generic | = help: Use the `type` keyword @@ -153,7 +152,7 @@ UP040.py:30:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t 29 | T = typing.TypeVar("T", covariant=True) 30 | x: typing.TypeAlias = list[T] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 -31 | +31 | 32 | # UP040 in class scope | = help: Use the `type` keyword @@ -174,7 +173,7 @@ UP040.py:36:5: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t 35 | # reference to global variable 36 | x: typing.TypeAlias = list[T] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 -37 | +37 | 38 | # reference to class variable | = help: Use the `type` keyword @@ -195,7 +194,7 @@ UP040.py:40:5: UP040 [*] Type alias `y` uses `TypeAlias` annotation instead of t 39 | TCLS = typing.TypeVar["TCLS"] 40 | y: typing.TypeAlias = list[TCLS] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 -41 | +41 | 42 | # UP040 won't add generics in fix | = help: Use the `type` keyword @@ -216,7 +215,7 @@ UP040.py:44:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t 43 | T = typing.TypeVar(*args) 44 | x: typing.TypeAlias = list[T] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 -45 | +45 | 46 | # OK | = help: Use the `type` keyword @@ -258,7 +257,7 @@ UP040.py:63:1: UP040 [*] Type alias `PositiveList` uses `TypeAliasType` assignme 64 | | "PositiveList", list[Annotated[T, Gt(0)]], type_params=(T,) 65 | | ) | |_^ UP040 -66 | +66 | 67 | # Bound | = help: Use the `type` keyword @@ -283,7 +282,7 @@ UP040.py:69:1: UP040 [*] Type alias `PositiveList` uses `TypeAliasType` assignme 70 | | "PositiveList", list[Annotated[T, Gt(0)]], type_params=(T,) 71 | | ) | |_^ UP040 -72 | +72 | 73 | # Multiple bounds | = help: Use the `type` keyword @@ -306,7 +305,7 @@ UP040.py:77:1: UP040 [*] Type alias `Tuple3` uses `TypeAliasType` assignment ins 76 | T3 = TypeVar("T3") 77 | Tuple3 = TypeAliasType("Tuple3", tuple[T1, T2, T3], type_params=(T1, T2, T3)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 -78 | +78 | 79 | # No type_params | = help: Use the `type` keyword @@ -346,7 +345,7 @@ UP040.py:81:1: UP040 [*] Type alias `PositiveInt` uses `TypeAliasType` assignmen 80 | PositiveInt = TypeAliasType("PositiveInt", Annotated[int, Gt(0)]) 81 | PositiveInt = TypeAliasType("PositiveInt", Annotated[int, Gt(0)], type_params=()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 -82 | +82 | 83 | # OK: Other name | = help: Use the `type` keyword diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__datetime_utc_alias_py311.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__datetime_utc_alias_py311.snap index 0794f714e440e..b236c324f19d5 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__datetime_utc_alias_py311.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__datetime_utc_alias_py311.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP017.py:10:11: UP017 [*] Use `datetime.UTC` alias | 8 | from datetime import timezone - 9 | + 9 | 10 | print(timezone.utc) | ^^^^^^^^^^^^ UP017 | @@ -29,7 +28,7 @@ UP017.py:10:11: UP017 [*] Use `datetime.UTC` alias UP017.py:16:11: UP017 [*] Use `datetime.UTC` alias | 14 | from datetime import timezone as tz -15 | +15 | 16 | print(tz.utc) | ^^^^^^ UP017 | @@ -53,7 +52,7 @@ UP017.py:16:11: UP017 [*] Use `datetime.UTC` alias UP017.py:22:11: UP017 [*] Use `datetime.UTC` alias | 20 | import datetime -21 | +21 | 22 | print(datetime.timezone.utc) | ^^^^^^^^^^^^^^^^^^^^^ UP017 | @@ -72,7 +71,7 @@ UP017.py:22:11: UP017 [*] Use `datetime.UTC` alias UP017.py:28:11: UP017 [*] Use `datetime.UTC` alias | 26 | import datetime as dt -27 | +27 | 28 | print(dt.timezone.utc) | ^^^^^^^^^^^^^^^ UP017 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p310.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p310.snap index a1794b6f27e15..eb69749335369 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p310.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p310.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- future_annotations.py:34:18: UP006 [*] Use `list` instead of `List` for type annotation | @@ -44,7 +43,7 @@ future_annotations.py:35:9: UP006 [*] Use `list` instead of `List` for type anno future_annotations.py:42:27: UP006 [*] Use `list` instead of `List` for type annotation | 40 | x: Optional[int] = None -41 | +41 | 42 | MyList: TypeAlias = Union[List[int], List[str]] | ^^^^ UP006 | @@ -60,7 +59,7 @@ future_annotations.py:42:27: UP006 [*] Use `list` instead of `List` for type ann future_annotations.py:42:38: UP006 [*] Use `list` instead of `List` for type annotation | 40 | x: Optional[int] = None -41 | +41 | 42 | MyList: TypeAlias = Union[List[int], List[str]] | ^^^^ UP006 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_py310.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_py310.snap index a1794b6f27e15..eb69749335369 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_py310.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_py310.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- future_annotations.py:34:18: UP006 [*] Use `list` instead of `List` for type annotation | @@ -44,7 +43,7 @@ future_annotations.py:35:9: UP006 [*] Use `list` instead of `List` for type anno future_annotations.py:42:27: UP006 [*] Use `list` instead of `List` for type annotation | 40 | x: Optional[int] = None -41 | +41 | 42 | MyList: TypeAlias = Union[List[int], List[str]] | ^^^^ UP006 | @@ -60,7 +59,7 @@ future_annotations.py:42:27: UP006 [*] Use `list` instead of `List` for type ann future_annotations.py:42:38: UP006 [*] Use `list` instead of `List` for type annotation | 40 | x: Optional[int] = None -41 | +41 | 42 | MyList: TypeAlias = Union[List[int], List[str]] | ^^^^ UP006 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_p37.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_p37.snap index ebd2b1f889daa..525b392e7c156 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_p37.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_p37.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- future_annotations.py:40:4: UP007 [*] Use `X | Y` for type annotations | 40 | x: Optional[int] = None | ^^^^^^^^^^^^^ UP007 -41 | +41 | 42 | MyList: TypeAlias = Union[List[int], List[str]] | = help: Convert to `X | Y` diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_py310.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_py310.snap index a010c8ef1909f..f88a3b32fb327 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_py310.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_py310.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- future_annotations.py:40:4: UP007 [*] Use `X | Y` for type annotations | 40 | x: Optional[int] = None | ^^^^^^^^^^^^^ UP007 -41 | +41 | 42 | MyList: TypeAlias = Union[List[int], List[str]] | = help: Convert to `X | Y` @@ -23,7 +22,7 @@ future_annotations.py:40:4: UP007 [*] Use `X | Y` for type annotations future_annotations.py:42:21: UP007 [*] Use `X | Y` for type annotations | 40 | x: Optional[int] = None -41 | +41 | 42 | MyList: TypeAlias = Union[List[int], List[str]] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP007 | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB105_FURB105.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB105_FURB105.py.snap index 986f9ddb26b84..f4db6c7a569d4 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB105_FURB105.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB105_FURB105.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB105.py:3:1: FURB105 [*] Unnecessary empty string passed to `print` | 1 | # Errors. -2 | +2 | 3 | print("") | ^^^^^^^^^ FURB105 4 | print("", sep=",") @@ -362,7 +361,7 @@ FURB105.py:21:1: FURB105 [*] Unnecessary separator passed to `print` 20 | print(sep="\t") 21 | print(sep=print(1)) | ^^^^^^^^^^^^^^^^^^^ FURB105 -22 | +22 | 23 | # OK. | = help: Remove separator diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB116_FURB116.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB116_FURB116.py.snap index 005971005c419..a19b474227e6b 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB116_FURB116.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB116_FURB116.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB116.py:6:7: FURB116 [*] Replace `oct` call with `f"{num:o}"` | 4 | return num -5 | +5 | 6 | print(oct(num)[2:]) # FURB116 | ^^^^^^^^^^^^ FURB116 7 | print(hex(num)[2:]) # FURB116 @@ -48,7 +47,7 @@ FURB116.py:8:7: FURB116 [*] Replace `bin` call with `f"{num:b}"` 7 | print(hex(num)[2:]) # FURB116 8 | print(bin(num)[2:]) # FURB116 | ^^^^^^^^^^^^ FURB116 - 9 | + 9 | 10 | print(oct(1337)[2:]) # FURB116 | = help: Replace with `f"{num:b}"` @@ -66,7 +65,7 @@ FURB116.py:8:7: FURB116 [*] Replace `bin` call with `f"{num:b}"` FURB116.py:10:7: FURB116 [*] Replace `oct` call with `f"{1337:o}"` | 8 | print(bin(num)[2:]) # FURB116 - 9 | + 9 | 10 | print(oct(1337)[2:]) # FURB116 | ^^^^^^^^^^^^^ FURB116 11 | print(hex(1337)[2:]) # FURB116 @@ -109,7 +108,7 @@ FURB116.py:12:7: FURB116 [*] Replace `bin` call with `f"{1337:b}"` 11 | print(hex(1337)[2:]) # FURB116 12 | print(bin(1337)[2:]) # FURB116 | ^^^^^^^^^^^^^ FURB116 -13 | +13 | 14 | print(bin(return_num())[2:]) # FURB116 (no autofix) | = help: Replace with `f"{1337:b}"` @@ -127,7 +126,7 @@ FURB116.py:12:7: FURB116 [*] Replace `bin` call with `f"{1337:b}"` FURB116.py:14:7: FURB116 Replace `bin` call with f-string | 12 | print(bin(1337)[2:]) # FURB116 -13 | +13 | 14 | print(bin(return_num())[2:]) # FURB116 (no autofix) | ^^^^^^^^^^^^^^^^^^^^^ FURB116 15 | print(bin(int(f"{num}"))[2:]) # FURB116 (no autofix) @@ -139,7 +138,7 @@ FURB116.py:15:7: FURB116 Replace `bin` call with f-string 14 | print(bin(return_num())[2:]) # FURB116 (no autofix) 15 | print(bin(int(f"{num}"))[2:]) # FURB116 (no autofix) | ^^^^^^^^^^^^^^^^^^^^^^ FURB116 -16 | +16 | 17 | ## invalid | = help: Replace with f-string diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB118_FURB118.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB118_FURB118.py.snap index 3d21ba0d73107..f2efa2fbb203c 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB118_FURB118.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB118_FURB118.py.snap @@ -68,7 +68,7 @@ FURB118.py:5:10: FURB118 [*] Use `operator.neg` instead of defining a lambda 4 | op_pos = lambda x: +x 5 | op_neg = lambda x: -x | ^^^^^^^^^^^^ FURB118 -6 | +6 | 7 | op_add = lambda x, y: x + y | = help: Replace with `operator.neg` @@ -88,7 +88,7 @@ FURB118.py:5:10: FURB118 [*] Use `operator.neg` instead of defining a lambda FURB118.py:7:10: FURB118 [*] Use `operator.add` instead of defining a lambda | 5 | op_neg = lambda x: -x -6 | +6 | 7 | op_add = lambda x, y: x + y | ^^^^^^^^^^^^^^^^^^ FURB118 8 | op_sub = lambda x, y: x - y @@ -410,7 +410,7 @@ FURB118.py:19:15: FURB118 [*] Use `operator.floordiv` instead of defining a lamb 18 | op_bitand = lambda x, y: x & y 19 | op_floordiv = lambda x, y: x // y | ^^^^^^^^^^^^^^^^^^^ FURB118 -20 | +20 | 21 | op_eq = lambda x, y: x == y | = help: Replace with `operator.floordiv` @@ -434,7 +434,7 @@ FURB118.py:19:15: FURB118 [*] Use `operator.floordiv` instead of defining a lamb FURB118.py:21:9: FURB118 [*] Use `operator.eq` instead of defining a lambda | 19 | op_floordiv = lambda x, y: x // y -20 | +20 | 21 | op_eq = lambda x, y: x == y | ^^^^^^^^^^^^^^^^^^^ FURB118 22 | op_ne = lambda x, y: x != y @@ -879,7 +879,7 @@ FURB118.py:89:17: FURB118 [*] Use `operator.itemgetter((1, slice(None)))` instea 88 | op_itemgetter = lambda x: x[:, 1] 89 | op_itemgetter = lambda x: x[1, :] | ^^^^^^^^^^^^^^^^^ FURB118 -90 | +90 | 91 | # With a slice, trivia is dropped | = help: Replace with `operator.itemgetter((1, slice(None)))` @@ -905,7 +905,7 @@ FURB118.py:92:17: FURB118 [*] Use `operator.itemgetter((1, slice(None)))` instea 91 | # With a slice, trivia is dropped 92 | op_itemgetter = lambda x: x[1, :] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB118 -93 | +93 | 94 | # Without a slice, trivia is retained | = help: Replace with `operator.itemgetter((1, slice(None)))` diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB129_FURB129.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB129_FURB129.py.snap index faa3ec53146a0..c11b60c272766 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB129_FURB129.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB129_FURB129.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB129.py:7:18: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly | @@ -70,7 +69,7 @@ FURB129.py:11:49: FURB129 [*] Instead of calling `readlines()`, iterate over fil 10 | b = {line.upper() for line in f.readlines()} 11 | c = {line.lower(): line.upper() for line in f.readlines()} | ^^^^^^^^^^^^^ FURB129 -12 | +12 | 13 | with Path("FURB129.py").open() as f: | = help: Remove `readlines()` @@ -107,7 +106,7 @@ FURB129.py:14:18: FURB129 [*] Instead of calling `readlines()`, iterate over fil FURB129.py:17:14: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly | 15 | pass -16 | +16 | 17 | for _line in open("FURB129.py").readlines(): | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB129 18 | pass @@ -127,7 +126,7 @@ FURB129.py:17:14: FURB129 [*] Instead of calling `readlines()`, iterate over fil FURB129.py:20:14: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly | 18 | pass -19 | +19 | 20 | for _line in Path("FURB129.py").open().readlines(): | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB129 21 | pass diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB131_FURB131.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB131_FURB131.py.snap index 4e9058da5fffd..8928bc8483956 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB131_FURB131.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB131_FURB131.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB131.py:11:1: FURB131 [*] Prefer `clear` over deleting a full slice | @@ -136,7 +135,7 @@ FURB131.py:48:5: FURB131 [*] Prefer `clear` over deleting a full slice 47 | # FURB131 48 | del x[:] | ^^^^^^^^ FURB131 -49 | +49 | 50 | x = 1 | = help: Replace with `clear()` @@ -157,7 +156,7 @@ FURB131.py:58:1: FURB131 [*] Prefer `clear` over deleting a full slice 57 | # FURB131 58 | del sneaky[:] | ^^^^^^^^^^^^^ FURB131 -59 | +59 | 60 | # these should not | = help: Replace with `clear()` diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB136_FURB136.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB136_FURB136.py.snap index 0299299bc0e45..91386ad5284a3 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB136_FURB136.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB136_FURB136.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB136.py:4:1: FURB136 [*] Replace `x if x > y else y` with `max(y, x)` | 2 | y = 2 -3 | +3 | 4 | x if x > y else y # FURB136 | ^^^^^^^^^^^^^^^^^ FURB136 -5 | +5 | 6 | x if x >= y else y # FURB136 | = help: Replace with `max(y, x)` @@ -26,10 +25,10 @@ FURB136.py:4:1: FURB136 [*] Replace `x if x > y else y` with `max(y, x)` FURB136.py:6:1: FURB136 [*] Replace `x if x >= y else y` with `max(x, y)` | 4 | x if x > y else y # FURB136 -5 | +5 | 6 | x if x >= y else y # FURB136 | ^^^^^^^^^^^^^^^^^^ FURB136 -7 | +7 | 8 | x if x < y else y # FURB136 | = help: Replace with `max(x, y)` @@ -47,10 +46,10 @@ FURB136.py:6:1: FURB136 [*] Replace `x if x >= y else y` with `max(x, y)` FURB136.py:8:1: FURB136 [*] Replace `x if x < y else y` with `min(y, x)` | 6 | x if x >= y else y # FURB136 - 7 | + 7 | 8 | x if x < y else y # FURB136 | ^^^^^^^^^^^^^^^^^ FURB136 - 9 | + 9 | 10 | x if x <= y else y # FURB136 | = help: Replace with `min(y, x)` @@ -68,10 +67,10 @@ FURB136.py:8:1: FURB136 [*] Replace `x if x < y else y` with `min(y, x)` FURB136.py:10:1: FURB136 [*] Replace `x if x <= y else y` with `min(x, y)` | 8 | x if x < y else y # FURB136 - 9 | + 9 | 10 | x if x <= y else y # FURB136 | ^^^^^^^^^^^^^^^^^^ FURB136 -11 | +11 | 12 | y if x > y else x # FURB136 | = help: Replace with `min(x, y)` @@ -89,10 +88,10 @@ FURB136.py:10:1: FURB136 [*] Replace `x if x <= y else y` with `min(x, y)` FURB136.py:12:1: FURB136 [*] Replace `y if x > y else x` with `min(x, y)` | 10 | x if x <= y else y # FURB136 -11 | +11 | 12 | y if x > y else x # FURB136 | ^^^^^^^^^^^^^^^^^ FURB136 -13 | +13 | 14 | y if x >= y else x # FURB136 | = help: Replace with `min(x, y)` @@ -110,10 +109,10 @@ FURB136.py:12:1: FURB136 [*] Replace `y if x > y else x` with `min(x, y)` FURB136.py:14:1: FURB136 [*] Replace `y if x >= y else x` with `min(y, x)` | 12 | y if x > y else x # FURB136 -13 | +13 | 14 | y if x >= y else x # FURB136 | ^^^^^^^^^^^^^^^^^^ FURB136 -15 | +15 | 16 | y if x < y else x # FURB136 | = help: Replace with `min(y, x)` @@ -131,10 +130,10 @@ FURB136.py:14:1: FURB136 [*] Replace `y if x >= y else x` with `min(y, x)` FURB136.py:16:1: FURB136 [*] Replace `y if x < y else x` with `max(x, y)` | 14 | y if x >= y else x # FURB136 -15 | +15 | 16 | y if x < y else x # FURB136 | ^^^^^^^^^^^^^^^^^ FURB136 -17 | +17 | 18 | y if x <= y else x # FURB136 | = help: Replace with `max(x, y)` @@ -152,10 +151,10 @@ FURB136.py:16:1: FURB136 [*] Replace `y if x < y else x` with `max(x, y)` FURB136.py:18:1: FURB136 [*] Replace `y if x <= y else x` with `max(y, x)` | 16 | y if x < y else x # FURB136 -17 | +17 | 18 | y if x <= y else x # FURB136 | ^^^^^^^^^^^^^^^^^^ FURB136 -19 | +19 | 20 | x + y if x > y else y # OK | = help: Replace with `max(y, x)` @@ -173,7 +172,7 @@ FURB136.py:18:1: FURB136 [*] Replace `y if x <= y else x` with `max(y, x)` FURB136.py:22:1: FURB136 [*] Replace `if` expression with `max(y, x)` | 20 | x + y if x > y else y # OK -21 | +21 | 22 | / x if ( 23 | | x 24 | | > y diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB140_FURB140.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB140_FURB140.py.snap index c9a123466a4df..7748edac5afc3 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB140_FURB140.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB140_FURB140.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB140.py:7:1: FURB140 [*] Use `itertools.starmap` instead of the generator | 6 | # FURB140 7 | [print(x, y) for x, y in zipped()] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB140 -8 | +8 | 9 | # FURB140 | = help: Replace with `itertools.starmap` @@ -31,7 +30,7 @@ FURB140.py:10:1: FURB140 [*] Use `itertools.starmap` instead of the generator 9 | # FURB140 10 | (print(x, y) for x, y in zipped()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB140 -11 | +11 | 12 | # FURB140 | = help: Replace with `itertools.starmap` @@ -79,7 +78,7 @@ FURB140.py:19:1: FURB140 [*] Use `itertools.starmap` instead of the generator 18 | # FURB140 19 | [print(x, y) for x, y in zipped()] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB140 -20 | +20 | 21 | # FURB140 | = help: Replace with `itertools.starmap` @@ -99,7 +98,7 @@ FURB140.py:22:1: FURB140 [*] Use `itertools.starmap` instead of the generator 21 | # FURB140 22 | (print(x, y) for x, y in zipped()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB140 -23 | +23 | 24 | # FURB140 | = help: Replace with `itertools.starmap` @@ -119,7 +118,7 @@ FURB140.py:25:1: FURB140 [*] Use `itertools.starmap` instead of the generator 24 | # FURB140 25 | {print(x, y) for x, y in zipped()} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB140 -26 | +26 | 27 | # FURB140 (check it still flags starred arguments). | = help: Replace with `itertools.starmap` @@ -181,7 +180,7 @@ FURB140.py:31:1: FURB140 [*] Use `itertools.starmap` instead of the generator 30 | (foo(*t) for t in [(85, 60), (100, 80)]) 31 | {foo(*t) for t in [(85, 60), (100, 80)]} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB140 -32 | +32 | 33 | # Non-errors. | = help: Replace with `itertools.starmap` diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB142_FURB142.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB142_FURB142.py.snap index 81965e9793150..18021e3544b28 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB142_FURB142.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB142_FURB142.py.snap @@ -1,15 +1,14 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB142.py:5:1: FURB142 [*] Use of `set.add()` in a for loop | 3 | s = set() -4 | +4 | 5 | / for x in [1, 2, 3]: 6 | | s.add(x) | |____________^ FURB142 -7 | +7 | 8 | for x in {1, 2, 3}: | = help: Replace with `.update()` @@ -28,11 +27,11 @@ FURB142.py:5:1: FURB142 [*] Use of `set.add()` in a for loop FURB142.py:8:1: FURB142 [*] Use of `set.add()` in a for loop | 6 | s.add(x) - 7 | + 7 | 8 | / for x in {1, 2, 3}: 9 | | s.add(x) | |____________^ FURB142 -10 | +10 | 11 | for x in (1, 2, 3): | = help: Replace with `.update()` @@ -51,11 +50,11 @@ FURB142.py:8:1: FURB142 [*] Use of `set.add()` in a for loop FURB142.py:11:1: FURB142 [*] Use of `set.add()` in a for loop | 9 | s.add(x) -10 | +10 | 11 | / for x in (1, 2, 3): 12 | | s.add(x) | |____________^ FURB142 -13 | +13 | 14 | for x in (1, 2, 3): | = help: Replace with `.update()` @@ -74,11 +73,11 @@ FURB142.py:11:1: FURB142 [*] Use of `set.add()` in a for loop FURB142.py:14:1: FURB142 [*] Use of `set.discard()` in a for loop | 12 | s.add(x) -13 | +13 | 14 | / for x in (1, 2, 3): 15 | | s.discard(x) | |________________^ FURB142 -16 | +16 | 17 | for x in (1, 2, 3): | = help: Replace with `.difference_update()` @@ -97,11 +96,11 @@ FURB142.py:14:1: FURB142 [*] Use of `set.discard()` in a for loop FURB142.py:17:1: FURB142 [*] Use of `set.add()` in a for loop | 15 | s.discard(x) -16 | +16 | 17 | / for x in (1, 2, 3): 18 | | s.add(x + 1) | |________________^ FURB142 -19 | +19 | 20 | for x, y in ((1, 2), (3, 4)): | = help: Replace with `.update()` @@ -120,11 +119,11 @@ FURB142.py:17:1: FURB142 [*] Use of `set.add()` in a for loop FURB142.py:20:1: FURB142 [*] Use of `set.add()` in a for loop | 18 | s.add(x + 1) -19 | +19 | 20 | / for x, y in ((1, 2), (3, 4)): 21 | | s.add((x, y)) | |_________________^ FURB142 -22 | +22 | 23 | num = 123 | = help: Replace with `.update()` @@ -143,11 +142,11 @@ FURB142.py:20:1: FURB142 [*] Use of `set.add()` in a for loop FURB142.py:25:1: FURB142 [*] Use of `set.add()` in a for loop | 23 | num = 123 -24 | +24 | 25 | / for x in (1, 2, 3): 26 | | s.add(num) | |______________^ FURB142 -27 | +27 | 28 | for x in (1, 2, 3): | = help: Replace with `.update()` @@ -166,11 +165,11 @@ FURB142.py:25:1: FURB142 [*] Use of `set.add()` in a for loop FURB142.py:28:1: FURB142 [*] Use of `set.add()` in a for loop | 26 | s.add(num) -27 | +27 | 28 | / for x in (1, 2, 3): 29 | | s.add((num, x)) | |___________________^ FURB142 -30 | +30 | 31 | for x in (1, 2, 3): | = help: Replace with `.update()` @@ -189,11 +188,11 @@ FURB142.py:28:1: FURB142 [*] Use of `set.add()` in a for loop FURB142.py:31:1: FURB142 [*] Use of `set.add()` in a for loop | 29 | s.add((num, x)) -30 | +30 | 31 | / for x in (1, 2, 3): 32 | | s.add(x + num) | |__________________^ FURB142 -33 | +33 | 34 | # False negative | = help: Replace with `.update()` diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB145_FURB145.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB145_FURB145.py.snap index 3cc3c1ece6eeb..176f2c59e5328 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB145_FURB145.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB145_FURB145.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB145.py:4:5: FURB145 [*] Prefer `copy` method over slicing | @@ -111,7 +110,7 @@ FURB145.py:9:7: FURB145 [*] Prefer `copy` method over slicing 8 | l[:] 9 | print(l[:]) | ^^^^ FURB145 -10 | +10 | 11 | # False negatives. | = help: Replace with `copy()` diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB148_FURB148.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB148_FURB148.py.snap index 76ccacebb21f8..a6b220ffee519 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB148_FURB148.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB148_FURB148.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB148.py:14:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead | @@ -24,7 +23,7 @@ FURB148.py:14:17: FURB148 [*] `enumerate` value is unused, use `for x in range(l FURB148.py:17:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead | 15 | print(index) -16 | +16 | 17 | for index, _ in enumerate(books, start=0): | ^^^^^^^^^ FURB148 18 | print(index) @@ -44,7 +43,7 @@ FURB148.py:17:17: FURB148 [*] `enumerate` value is unused, use `for x in range(l FURB148.py:20:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead | 18 | print(index) -19 | +19 | 20 | for index, _ in enumerate(books, 0): | ^^^^^^^^^ FURB148 21 | print(index) @@ -64,7 +63,7 @@ FURB148.py:20:17: FURB148 [*] `enumerate` value is unused, use `for x in range(l FURB148.py:23:17: FURB148 `enumerate` value is unused, use `for x in range(len(y))` instead | 21 | print(index) -22 | +22 | 23 | for index, _ in enumerate(books, start=1): | ^^^^^^^^^ FURB148 24 | print(index) @@ -74,7 +73,7 @@ FURB148.py:23:17: FURB148 `enumerate` value is unused, use `for x in range(len(y FURB148.py:26:17: FURB148 `enumerate` value is unused, use `for x in range(len(y))` instead | 24 | print(index) -25 | +25 | 26 | for index, _ in enumerate(books, 1): | ^^^^^^^^^ FURB148 27 | print(index) @@ -84,7 +83,7 @@ FURB148.py:26:17: FURB148 `enumerate` value is unused, use `for x in range(len(y FURB148.py:29:17: FURB148 `enumerate` value is unused, use `for x in range(len(y))` instead | 27 | print(index) -28 | +28 | 29 | for index, _ in enumerate(books, start=x): | ^^^^^^^^^ FURB148 30 | print(book) @@ -94,7 +93,7 @@ FURB148.py:29:17: FURB148 `enumerate` value is unused, use `for x in range(len(y FURB148.py:32:17: FURB148 `enumerate` value is unused, use `for x in range(len(y))` instead | 30 | print(book) -31 | +31 | 32 | for index, _ in enumerate(books, x): | ^^^^^^^^^ FURB148 33 | print(book) @@ -104,7 +103,7 @@ FURB148.py:32:17: FURB148 `enumerate` value is unused, use `for x in range(len(y FURB148.py:35:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead | 33 | print(book) -34 | +34 | 35 | for _, book in enumerate(books): | ^^^^^^^^^ FURB148 36 | print(book) @@ -124,7 +123,7 @@ FURB148.py:35:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst FURB148.py:38:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead | 36 | print(book) -37 | +37 | 38 | for _, book in enumerate(books, start=0): | ^^^^^^^^^ FURB148 39 | print(book) @@ -144,7 +143,7 @@ FURB148.py:38:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst FURB148.py:41:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead | 39 | print(book) -40 | +40 | 41 | for _, book in enumerate(books, 0): | ^^^^^^^^^ FURB148 42 | print(book) @@ -164,7 +163,7 @@ FURB148.py:41:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst FURB148.py:44:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead | 42 | print(book) -43 | +43 | 44 | for _, book in enumerate(books, start=1): | ^^^^^^^^^ FURB148 45 | print(book) @@ -184,7 +183,7 @@ FURB148.py:44:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst FURB148.py:47:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead | 45 | print(book) -46 | +46 | 47 | for _, book in enumerate(books, 1): | ^^^^^^^^^ FURB148 48 | print(book) @@ -204,7 +203,7 @@ FURB148.py:47:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst FURB148.py:50:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead | 48 | print(book) -49 | +49 | 50 | for _, book in enumerate(books, start=x): | ^^^^^^^^^ FURB148 51 | print(book) @@ -224,7 +223,7 @@ FURB148.py:50:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst FURB148.py:53:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead | 51 | print(book) -52 | +52 | 53 | for _, book in enumerate(books, x): | ^^^^^^^^^ FURB148 54 | print(book) @@ -244,7 +243,7 @@ FURB148.py:53:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst FURB148.py:56:22: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead | 54 | print(book) -55 | +55 | 56 | for index, (_, _) in enumerate(books): | ^^^^^^^^^ FURB148 57 | print(index) @@ -264,7 +263,7 @@ FURB148.py:56:22: FURB148 [*] `enumerate` value is unused, use `for x in range(l FURB148.py:59:21: FURB148 [*] `enumerate` index is unused, use `for x in y` instead | 57 | print(index) -58 | +58 | 59 | for (_, _), book in enumerate(books): | ^^^^^^^^^ FURB148 60 | print(book) @@ -284,7 +283,7 @@ FURB148.py:59:21: FURB148 [*] `enumerate` index is unused, use `for x in y` inst FURB148.py:62:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead | 60 | print(book) -61 | +61 | 62 | for(index, _)in enumerate(books): | ^^^^^^^^^ FURB148 63 | print(index) @@ -304,7 +303,7 @@ FURB148.py:62:17: FURB148 [*] `enumerate` value is unused, use `for x in range(l FURB148.py:65:18: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead | 63 | print(index) -64 | +64 | 65 | for(index), _ in enumerate(books): | ^^^^^^^^^ FURB148 66 | print(index) @@ -324,7 +323,7 @@ FURB148.py:65:18: FURB148 [*] `enumerate` value is unused, use `for x in range(l FURB148.py:68:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead | 66 | print(index) -67 | +67 | 68 | for index, _ in enumerate(books_and_authors): | ^^^^^^^^^ FURB148 69 | print(index) @@ -344,7 +343,7 @@ FURB148.py:68:17: FURB148 [*] `enumerate` value is unused, use `for x in range(l FURB148.py:71:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead | 69 | print(index) -70 | +70 | 71 | for _, book in enumerate(books_and_authors): | ^^^^^^^^^ FURB148 72 | print(book) @@ -364,7 +363,7 @@ FURB148.py:71:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst FURB148.py:74:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead | 72 | print(book) -73 | +73 | 74 | for index, _ in enumerate(books_set): | ^^^^^^^^^ FURB148 75 | print(index) @@ -384,7 +383,7 @@ FURB148.py:74:17: FURB148 [*] `enumerate` value is unused, use `for x in range(l FURB148.py:77:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead | 75 | print(index) -76 | +76 | 77 | for _, book in enumerate(books_set): | ^^^^^^^^^ FURB148 78 | print(book) @@ -404,7 +403,7 @@ FURB148.py:77:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst FURB148.py:80:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead | 78 | print(book) -79 | +79 | 80 | for index, _ in enumerate(books_tuple): | ^^^^^^^^^ FURB148 81 | print(index) @@ -424,7 +423,7 @@ FURB148.py:80:17: FURB148 [*] `enumerate` value is unused, use `for x in range(l FURB148.py:83:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead | 81 | print(index) -82 | +82 | 83 | for _, book in enumerate(books_tuple): | ^^^^^^^^^ FURB148 84 | print(book) diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap index 4714a3437bf93..c51afdd85aee0 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB152.py:3:5: FURB152 [*] Replace `3.14` with `math.pi` | 1 | r = 3.1 # OK -2 | +2 | 3 | A = 3.14 * r ** 2 # FURB152 | ^^^^ FURB152 -4 | +4 | 5 | C = 6.28 * r # FURB152 | = help: Use `math.pi` @@ -26,10 +25,10 @@ FURB152.py:3:5: FURB152 [*] Replace `3.14` with `math.pi` FURB152.py:5:5: FURB152 [*] Replace `6.28` with `math.tau` | 3 | A = 3.14 * r ** 2 # FURB152 -4 | +4 | 5 | C = 6.28 * r # FURB152 | ^^^^ FURB152 -6 | +6 | 7 | e = 2.71 # FURB152 | = help: Use `math.tau` @@ -49,10 +48,10 @@ FURB152.py:5:5: FURB152 [*] Replace `6.28` with `math.tau` FURB152.py:7:5: FURB152 [*] Replace `2.71` with `math.e` | 5 | C = 6.28 * r # FURB152 -6 | +6 | 7 | e = 2.71 # FURB152 | ^^^^ FURB152 -8 | +8 | 9 | r = 3.15 # OK | = help: Use `math.e` @@ -74,10 +73,10 @@ FURB152.py:7:5: FURB152 [*] Replace `2.71` with `math.e` FURB152.py:11:5: FURB152 [*] Replace `3.141` with `math.pi` | 9 | r = 3.15 # OK -10 | +10 | 11 | r = 3.141 # FURB152 | ^^^^^ FURB152 -12 | +12 | 13 | r = 3.142 # FURB152 | = help: Use `math.pi` @@ -100,10 +99,10 @@ FURB152.py:11:5: FURB152 [*] Replace `3.141` with `math.pi` FURB152.py:13:5: FURB152 [*] Replace `3.142` with `math.pi` | 11 | r = 3.141 # FURB152 -12 | +12 | 13 | r = 3.142 # FURB152 | ^^^^^ FURB152 -14 | +14 | 15 | r = 3.1415 # FURB152 | = help: Use `math.pi` @@ -126,10 +125,10 @@ FURB152.py:13:5: FURB152 [*] Replace `3.142` with `math.pi` FURB152.py:15:5: FURB152 [*] Replace `3.1415` with `math.pi` | 13 | r = 3.142 # FURB152 -14 | +14 | 15 | r = 3.1415 # FURB152 | ^^^^^^ FURB152 -16 | +16 | 17 | r = 3.1416 # FURB152 | = help: Use `math.pi` @@ -152,10 +151,10 @@ FURB152.py:15:5: FURB152 [*] Replace `3.1415` with `math.pi` FURB152.py:17:5: FURB152 [*] Replace `3.1416` with `math.pi` | 15 | r = 3.1415 # FURB152 -16 | +16 | 17 | r = 3.1416 # FURB152 | ^^^^^^ FURB152 -18 | +18 | 19 | r = 3.141592 # FURB152 | = help: Use `math.pi` @@ -178,10 +177,10 @@ FURB152.py:17:5: FURB152 [*] Replace `3.1416` with `math.pi` FURB152.py:19:5: FURB152 [*] Replace `3.141592` with `math.pi` | 17 | r = 3.1416 # FURB152 -18 | +18 | 19 | r = 3.141592 # FURB152 | ^^^^^^^^ FURB152 -20 | +20 | 21 | r = 3.141593 # FURB152 | = help: Use `math.pi` @@ -204,10 +203,10 @@ FURB152.py:19:5: FURB152 [*] Replace `3.141592` with `math.pi` FURB152.py:21:5: FURB152 [*] Replace `3.141593` with `math.pi` | 19 | r = 3.141592 # FURB152 -20 | +20 | 21 | r = 3.141593 # FURB152 | ^^^^^^^^ FURB152 -22 | +22 | 23 | r = 3.14159265 # FURB152 | = help: Use `math.pi` @@ -230,10 +229,10 @@ FURB152.py:21:5: FURB152 [*] Replace `3.141593` with `math.pi` FURB152.py:23:5: FURB152 [*] Replace `3.14159265` with `math.pi` | 21 | r = 3.141593 # FURB152 -22 | +22 | 23 | r = 3.14159265 # FURB152 | ^^^^^^^^^^ FURB152 -24 | +24 | 25 | r = 3.141592653589793238462643383279 # FURB152 | = help: Use `math.pi` @@ -256,10 +255,10 @@ FURB152.py:23:5: FURB152 [*] Replace `3.14159265` with `math.pi` FURB152.py:25:5: FURB152 [*] Replace `3.141592653589793238462643383279` with `math.pi` | 23 | r = 3.14159265 # FURB152 -24 | +24 | 25 | r = 3.141592653589793238462643383279 # FURB152 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB152 -26 | +26 | 27 | r = 3.14159266 # OK | = help: Use `math.pi` @@ -282,10 +281,10 @@ FURB152.py:25:5: FURB152 [*] Replace `3.141592653589793238462643383279` with `ma FURB152.py:31:5: FURB152 [*] Replace `2.718` with `math.e` | 29 | e = 2.7 # OK -30 | +30 | 31 | e = 2.718 # FURB152 | ^^^^^ FURB152 -32 | +32 | 33 | e = 2.7182 # FURB152 | = help: Use `math.e` @@ -308,10 +307,10 @@ FURB152.py:31:5: FURB152 [*] Replace `2.718` with `math.e` FURB152.py:33:5: FURB152 [*] Replace `2.7182` with `math.e` | 31 | e = 2.718 # FURB152 -32 | +32 | 33 | e = 2.7182 # FURB152 | ^^^^^^ FURB152 -34 | +34 | 35 | e = 2.7183 # FURB152 | = help: Use `math.e` @@ -334,10 +333,10 @@ FURB152.py:33:5: FURB152 [*] Replace `2.7182` with `math.e` FURB152.py:35:5: FURB152 [*] Replace `2.7183` with `math.e` | 33 | e = 2.7182 # FURB152 -34 | +34 | 35 | e = 2.7183 # FURB152 | ^^^^^^ FURB152 -36 | +36 | 37 | e = 2.719 # OK | = help: Use `math.e` @@ -360,7 +359,7 @@ FURB152.py:35:5: FURB152 [*] Replace `2.7183` with `math.e` FURB152.py:45:5: FURB152 [*] Replace `2.7182000000000001` with `math.e` | 43 | e = 2.718200000000001 # OK -44 | +44 | 45 | e = 2.7182000000000001 # FURB152 | ^^^^^^^^^^^^^^^^^^ FURB152 | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB157_FURB157.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB157_FURB157.py.snap index 967e552a1b2c8..4ead349089d47 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB157_FURB157.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB157_FURB157.py.snap @@ -152,7 +152,7 @@ FURB157.py:12:17: FURB157 [*] Verbose expression in `Decimal` constructor 11 | Decimal(float("nan")) 12 | decimal.Decimal("0") | ^^^ FURB157 -13 | +13 | 14 | # OK | = help: Replace with `0` @@ -192,7 +192,7 @@ FURB157.py:24:9: FURB157 [*] Verbose expression in `Decimal` constructor 23 | Decimal("1_000") 24 | Decimal("__1____000") | ^^^^^^^^^^^^ FURB157 -25 | +25 | 26 | # Ok | = help: Replace with `1000` diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB161_FURB161.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB161_FURB161.py.snap index d9385176d90b1..7888f39f7dee0 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB161_FURB161.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB161_FURB161.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB161.py:6:9: FURB161 [*] Use of `bin(x).count('1')` | 4 | return 10 -5 | +5 | 6 | count = bin(x).count("1") # FURB161 | ^^^^^^^^^^^^^^^^^ FURB161 7 | count = bin(10).count("1") # FURB161 @@ -174,7 +173,7 @@ FURB161.py:14:9: FURB161 [*] Use of `bin("10" "15").count('1')` 13 | count = bin((10)).count("1") # FURB161 14 | count = bin("10" "15").count("1") # FURB161 | ^^^^^^^^^^^^^^^^^^^^^^^^^ FURB161 -15 | +15 | 16 | count = x.bit_count() # OK | = help: Replace with `("10" "15").bit_count()` diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB163_FURB163.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB163_FURB163.py.snap index 32df4b1d7d088..0985c7f1c9117 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB163_FURB163.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB163_FURB163.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB163.py:4:1: FURB163 [*] Prefer `math.log2(1)` over `math.log` with a redundant base | @@ -153,7 +152,7 @@ FURB163.py:12:1: FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redun 11 | math.log(1, 2.0) 12 | math.log(1, 10.0) | ^^^^^^^^^^^^^^^^^ FURB163 -13 | +13 | 14 | # OK | = help: Replace with `math.log10(1)` diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB164_FURB164.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB164_FURB164.py.snap index d07e82b376be3..e15af106a498f 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB164_FURB164.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB164_FURB164.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB164.py:7:5: FURB164 [*] Verbose method `from_float` in `Fraction` construction | @@ -342,7 +341,7 @@ FURB164.py:22:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi 21 | _ = Decimal.from_float(float("-Infinity")) 22 | _ = Decimal.from_float(float("nan")) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 -23 | +23 | 24 | # OK | = help: Replace with `Decimal` constructor diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB166_FURB166.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB166_FURB166.py.snap index 4f698d413646f..162b036f6a115 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB166_FURB166.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB166_FURB166.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB166.py:3:5: FURB166 [*] Use of `int` with explicit `base=2` after removing prefix | 1 | # Errors -2 | +2 | 3 | _ = int("0b1010"[2:], 2) | ^^^^^^^^^^^^^^^^^^^^ FURB166 4 | _ = int("0o777"[2:], 8) @@ -47,7 +46,7 @@ FURB166.py:5:5: FURB166 [*] Use of `int` with explicit `base=16` after removing 4 | _ = int("0o777"[2:], 8) 5 | _ = int("0xFFFF"[2:], 16) | ^^^^^^^^^^^^^^^^^^^^^ FURB166 -6 | +6 | 7 | b = "0b11" | = help: Replace with `base=0` @@ -67,7 +66,7 @@ FURB166.py:8:5: FURB166 [*] Use of `int` with explicit `base=2` after removing p 7 | b = "0b11" 8 | _ = int(b[2:], 2) | ^^^^^^^^^^^^^ FURB166 - 9 | + 9 | 10 | _ = int("0xFFFF"[2:], base=16) | = help: Replace with `base=0` @@ -85,10 +84,10 @@ FURB166.py:8:5: FURB166 [*] Use of `int` with explicit `base=2` after removing p FURB166.py:10:5: FURB166 [*] Use of `int` with explicit `base=16` after removing prefix | 8 | _ = int(b[2:], 2) - 9 | + 9 | 10 | _ = int("0xFFFF"[2:], base=16) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB166 -11 | +11 | 12 | _ = int(b"0xFFFF"[2:], 16) | = help: Replace with `base=0` @@ -106,7 +105,7 @@ FURB166.py:10:5: FURB166 [*] Use of `int` with explicit `base=16` after removing FURB166.py:12:5: FURB166 [*] Use of `int` with explicit `base=16` after removing prefix | 10 | _ = int("0xFFFF"[2:], base=16) -11 | +11 | 12 | _ = int(b"0xFFFF"[2:], 16) | ^^^^^^^^^^^^^^^^^^^^^^ FURB166 | @@ -126,7 +125,7 @@ FURB166.py:19:5: FURB166 [*] Use of `int` with explicit `base=16` after removing | 19 | _ = int(get_str()[2:], 16) | ^^^^^^^^^^^^^^^^^^^^^^ FURB166 -20 | +20 | 21 | # OK | = help: Replace with `base=0` diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB168_FURB168.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB168_FURB168.py.snap index c27d38bc58abf..4afe7602fb212 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB168_FURB168.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB168_FURB168.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB168.py:5:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` | 3 | # Errors. -4 | +4 | 5 | if isinstance(foo, type(None)): | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB168 6 | pass @@ -25,7 +24,7 @@ FURB168.py:5:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if a FURB168.py:8:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` | 6 | pass -7 | +7 | 8 | if isinstance(foo, (type(None))): | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB168 9 | pass @@ -45,7 +44,7 @@ FURB168.py:8:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if a FURB168.py:11:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` | 9 | pass -10 | +10 | 11 | if isinstance(foo, (type(None), type(None), type(None))): | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB168 12 | pass @@ -65,7 +64,7 @@ FURB168.py:11:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if FURB168.py:14:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` | 12 | pass -13 | +13 | 14 | if isinstance(foo, None | None): | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB168 15 | pass @@ -85,7 +84,7 @@ FURB168.py:14:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if FURB168.py:17:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` | 15 | pass -16 | +16 | 17 | if isinstance(foo, (None | None)): | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB168 18 | pass @@ -105,7 +104,7 @@ FURB168.py:17:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if FURB168.py:20:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` | 18 | pass -19 | +19 | 20 | if isinstance(foo, None | type(None)): | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB168 21 | pass @@ -125,7 +124,7 @@ FURB168.py:20:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if FURB168.py:23:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` | 21 | pass -22 | +22 | 23 | if isinstance(foo, (None | type(None))): | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB168 24 | pass diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB169_FURB169.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB169_FURB169.py.snap index 6db38df6cb086..2c98aa98d3e00 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB169_FURB169.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB169_FURB169.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB169.py:5:1: FURB169 [*] Compare the identities of `foo` and `None` instead of their respective types | 3 | # Error. -4 | +4 | 5 | type(foo) is type(None) | ^^^^^^^^^^^^^^^^^^^^^^^ FURB169 -6 | +6 | 7 | type(None) is type(foo) | = help: Replace with `foo is None` @@ -26,10 +25,10 @@ FURB169.py:5:1: FURB169 [*] Compare the identities of `foo` and `None` instead o FURB169.py:7:1: FURB169 [*] Compare the identities of `foo` and `None` instead of their respective types | 5 | type(foo) is type(None) -6 | +6 | 7 | type(None) is type(foo) | ^^^^^^^^^^^^^^^^^^^^^^^ FURB169 -8 | +8 | 9 | type(None) is type(None) | = help: Replace with `foo is None` @@ -47,10 +46,10 @@ FURB169.py:7:1: FURB169 [*] Compare the identities of `foo` and `None` instead o FURB169.py:9:1: FURB169 [*] Compare the identities of `None` and `None` instead of their respective types | 7 | type(None) is type(foo) - 8 | + 8 | 9 | type(None) is type(None) | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB169 -10 | +10 | 11 | type(foo) is not type(None) | = help: Replace with `None is None` @@ -68,10 +67,10 @@ FURB169.py:9:1: FURB169 [*] Compare the identities of `None` and `None` instead FURB169.py:11:1: FURB169 [*] Compare the identities of `foo` and `None` instead of their respective types | 9 | type(None) is type(None) -10 | +10 | 11 | type(foo) is not type(None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB169 -12 | +12 | 13 | type(None) is not type(foo) | = help: Replace with `foo is not None` @@ -89,10 +88,10 @@ FURB169.py:11:1: FURB169 [*] Compare the identities of `foo` and `None` instead FURB169.py:13:1: FURB169 [*] Compare the identities of `foo` and `None` instead of their respective types | 11 | type(foo) is not type(None) -12 | +12 | 13 | type(None) is not type(foo) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB169 -14 | +14 | 15 | type(None) is not type(None) | = help: Replace with `foo is not None` @@ -110,10 +109,10 @@ FURB169.py:13:1: FURB169 [*] Compare the identities of `foo` and `None` instead FURB169.py:15:1: FURB169 [*] Compare the identities of `None` and `None` instead of their respective types | 13 | type(None) is not type(foo) -14 | +14 | 15 | type(None) is not type(None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB169 -16 | +16 | 17 | type(foo) == type(None) | = help: Replace with `None is not None` @@ -131,10 +130,10 @@ FURB169.py:15:1: FURB169 [*] Compare the identities of `None` and `None` instead FURB169.py:17:1: FURB169 [*] Compare the identities of `foo` and `None` instead of their respective types | 15 | type(None) is not type(None) -16 | +16 | 17 | type(foo) == type(None) | ^^^^^^^^^^^^^^^^^^^^^^^ FURB169 -18 | +18 | 19 | type(None) == type(foo) | = help: Replace with `foo is None` @@ -152,10 +151,10 @@ FURB169.py:17:1: FURB169 [*] Compare the identities of `foo` and `None` instead FURB169.py:19:1: FURB169 [*] Compare the identities of `foo` and `None` instead of their respective types | 17 | type(foo) == type(None) -18 | +18 | 19 | type(None) == type(foo) | ^^^^^^^^^^^^^^^^^^^^^^^ FURB169 -20 | +20 | 21 | type(None) == type(None) | = help: Replace with `foo is None` @@ -173,10 +172,10 @@ FURB169.py:19:1: FURB169 [*] Compare the identities of `foo` and `None` instead FURB169.py:21:1: FURB169 [*] Compare the identities of `None` and `None` instead of their respective types | 19 | type(None) == type(foo) -20 | +20 | 21 | type(None) == type(None) | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB169 -22 | +22 | 23 | type(foo) != type(None) | = help: Replace with `None is None` @@ -194,10 +193,10 @@ FURB169.py:21:1: FURB169 [*] Compare the identities of `None` and `None` instead FURB169.py:23:1: FURB169 [*] Compare the identities of `foo` and `None` instead of their respective types | 21 | type(None) == type(None) -22 | +22 | 23 | type(foo) != type(None) | ^^^^^^^^^^^^^^^^^^^^^^^ FURB169 -24 | +24 | 25 | type(None) != type(foo) | = help: Replace with `foo is not None` @@ -215,10 +214,10 @@ FURB169.py:23:1: FURB169 [*] Compare the identities of `foo` and `None` instead FURB169.py:25:1: FURB169 [*] Compare the identities of `foo` and `None` instead of their respective types | 23 | type(foo) != type(None) -24 | +24 | 25 | type(None) != type(foo) | ^^^^^^^^^^^^^^^^^^^^^^^ FURB169 -26 | +26 | 27 | type(None) != type(None) | = help: Replace with `foo is not None` @@ -236,10 +235,10 @@ FURB169.py:25:1: FURB169 [*] Compare the identities of `foo` and `None` instead FURB169.py:27:1: FURB169 [*] Compare the identities of `None` and `None` instead of their respective types | 25 | type(None) != type(foo) -26 | +26 | 27 | type(None) != type(None) | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB169 -28 | +28 | 29 | # Ok. | = help: Replace with `None is not None` diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB171_FURB171.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB171_FURB171.py.snap index 7124e3e5c7f8d..5aab5d8010f42 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB171_FURB171.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB171_FURB171.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB171.py:3:4: FURB171 [*] Membership test against single-item container | 1 | # Errors. -2 | +2 | 3 | if 1 in (1,): | ^^^^^^^^^ FURB171 4 | print("Single-element tuple") @@ -24,7 +23,7 @@ FURB171.py:3:4: FURB171 [*] Membership test against single-item container FURB171.py:6:4: FURB171 [*] Membership test against single-item container | 4 | print("Single-element tuple") -5 | +5 | 6 | if 1 in [1]: | ^^^^^^^^ FURB171 7 | print("Single-element list") @@ -44,7 +43,7 @@ FURB171.py:6:4: FURB171 [*] Membership test against single-item container FURB171.py:9:4: FURB171 [*] Membership test against single-item container | 7 | print("Single-element list") - 8 | + 8 | 9 | if 1 in {1}: | ^^^^^^^^ FURB171 10 | print("Single-element set") @@ -64,7 +63,7 @@ FURB171.py:9:4: FURB171 [*] Membership test against single-item container FURB171.py:12:4: FURB171 [*] Membership test against single-item container | 10 | print("Single-element set") -11 | +11 | 12 | if "a" in "a": | ^^^^^^^^^^ FURB171 13 | print("Single-element string") @@ -84,7 +83,7 @@ FURB171.py:12:4: FURB171 [*] Membership test against single-item container FURB171.py:15:4: FURB171 [*] Membership test against single-item container | 13 | print("Single-element string") -14 | +14 | 15 | if 1 not in (1,): | ^^^^^^^^^^^^^ FURB171 16 | print("Check `not in` membership test") @@ -104,7 +103,7 @@ FURB171.py:15:4: FURB171 [*] Membership test against single-item container FURB171.py:18:8: FURB171 [*] Membership test against single-item container | 16 | print("Check `not in` membership test") -17 | +17 | 18 | if not 1 in (1,): | ^^^^^^^^^ FURB171 19 | print("Check the negated membership test") diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB177_FURB177.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB177_FURB177.py.snap index e87eb04f57f5a..567479ed72a7b 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB177_FURB177.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB177_FURB177.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB177.py:5:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups | @@ -27,7 +26,7 @@ FURB177.py:6:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for curr 5 | _ = Path().resolve() 6 | _ = pathlib.Path().resolve() | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB177 -7 | +7 | 8 | _ = Path("").resolve() | = help: Replace `Path().resolve()` with `Path.cwd()` @@ -45,7 +44,7 @@ FURB177.py:6:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for curr FURB177.py:8:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups | 6 | _ = pathlib.Path().resolve() -7 | +7 | 8 | _ = Path("").resolve() | ^^^^^^^^^^^^^^^^^^ FURB177 9 | _ = pathlib.Path("").resolve() @@ -67,7 +66,7 @@ FURB177.py:9:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for curr 8 | _ = Path("").resolve() 9 | _ = pathlib.Path("").resolve() | ^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB177 -10 | +10 | 11 | _ = Path(".").resolve() | = help: Replace `Path().resolve()` with `Path.cwd()` @@ -85,7 +84,7 @@ FURB177.py:9:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for curr FURB177.py:11:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups | 9 | _ = pathlib.Path("").resolve() -10 | +10 | 11 | _ = Path(".").resolve() | ^^^^^^^^^^^^^^^^^^^ FURB177 12 | _ = pathlib.Path(".").resolve() @@ -107,7 +106,7 @@ FURB177.py:12:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for cur 11 | _ = Path(".").resolve() 12 | _ = pathlib.Path(".").resolve() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB177 -13 | +13 | 14 | _ = Path("", **kwargs).resolve() | = help: Replace `Path().resolve()` with `Path.cwd()` @@ -125,7 +124,7 @@ FURB177.py:12:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for cur FURB177.py:14:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups | 12 | _ = pathlib.Path(".").resolve() -13 | +13 | 14 | _ = Path("", **kwargs).resolve() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB177 15 | _ = pathlib.Path("", **kwargs).resolve() @@ -147,7 +146,7 @@ FURB177.py:15:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for cur 14 | _ = Path("", **kwargs).resolve() 15 | _ = pathlib.Path("", **kwargs).resolve() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB177 -16 | +16 | 17 | _ = Path(".", **kwargs).resolve() | = help: Replace `Path().resolve()` with `Path.cwd()` @@ -165,7 +164,7 @@ FURB177.py:15:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for cur FURB177.py:17:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups | 15 | _ = pathlib.Path("", **kwargs).resolve() -16 | +16 | 17 | _ = Path(".", **kwargs).resolve() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB177 18 | _ = pathlib.Path(".", **kwargs).resolve() @@ -187,7 +186,7 @@ FURB177.py:18:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for cur 17 | _ = Path(".", **kwargs).resolve() 18 | _ = pathlib.Path(".", **kwargs).resolve() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB177 -19 | +19 | 20 | # OK | = help: Replace `Path().resolve()` with `Path.cwd()` diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB180_FURB180.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB180_FURB180.py.snap index 5ecf72dfa7353..45df8c8e53cea 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB180_FURB180.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB180_FURB180.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB180.py:7:10: FURB180 [*] Use of `metaclass=abc.ABCMeta` to define abstract base class | 5 | # Errors -6 | +6 | 7 | class A0(metaclass=abc.ABCMeta): | ^^^^^^^^^^^^^^^^^^^^^ FURB180 8 | @abstractmethod diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB181_FURB181.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB181_FURB181.py.snap index f602872c8896e..82cea760eaea9 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB181_FURB181.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB181_FURB181.py.snap @@ -4,7 +4,7 @@ source: crates/ruff_linter/src/rules/refurb/mod.rs FURB181.py:19:1: FURB181 [*] Use of hashlib's `.digest().hex()` | 17 | # these will match -18 | +18 | 19 | blake2b().digest().hex() | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB181 20 | blake2s().digest().hex() @@ -268,7 +268,7 @@ FURB181.py:32:1: FURB181 Use of hashlib's `.digest().hex()` 31 | shake_128().digest(10).hex() 32 | shake_256().digest(10).hex() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB181 -33 | +33 | 34 | hashlib.sha256().digest().hex() | = help: Replace with `.hexdigest()` @@ -276,10 +276,10 @@ FURB181.py:32:1: FURB181 Use of hashlib's `.digest().hex()` FURB181.py:34:1: FURB181 [*] Use of hashlib's `.digest().hex()` | 32 | shake_256().digest(10).hex() -33 | +33 | 34 | hashlib.sha256().digest().hex() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB181 -35 | +35 | 36 | sha256(b"text").digest().hex() | = help: Replace with `.hexdigest()` @@ -297,10 +297,10 @@ FURB181.py:34:1: FURB181 [*] Use of hashlib's `.digest().hex()` FURB181.py:36:1: FURB181 [*] Use of hashlib's `.digest().hex()` | 34 | hashlib.sha256().digest().hex() -35 | +35 | 36 | sha256(b"text").digest().hex() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB181 -37 | +37 | 38 | hash_algo().digest().hex() | = help: Replace with `.hexdigest()` @@ -318,10 +318,10 @@ FURB181.py:36:1: FURB181 [*] Use of hashlib's `.digest().hex()` FURB181.py:38:1: FURB181 [*] Use of hashlib's `.digest().hex()` | 36 | sha256(b"text").digest().hex() -37 | +37 | 38 | hash_algo().digest().hex() | ^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB181 -39 | +39 | 40 | # not yet supported | = help: Replace with `.hexdigest()` diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB189_FURB189.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB189_FURB189.py.snap index 714df9487f963..43855d425b434 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB189_FURB189.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB189_FURB189.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB189.py:17:9: FURB189 [*] Subclassing `dict` can be error prone, use `collections.UserDict` instead | @@ -32,7 +31,7 @@ FURB189.py:17:9: FURB189 [*] Subclassing `dict` can be error prone, use `collect FURB189.py:20:9: FURB189 [*] Subclassing `list` can be error prone, use `collections.UserList` instead | 18 | pass -19 | +19 | 20 | class L(list): | ^^^^ FURB189 21 | pass @@ -52,7 +51,7 @@ FURB189.py:20:9: FURB189 [*] Subclassing `list` can be error prone, use `collect FURB189.py:23:9: FURB189 [*] Subclassing `str` can be error prone, use `collections.UserString` instead | 21 | pass -22 | +22 | 23 | class S(str): | ^^^ FURB189 24 | pass diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB192_FURB192.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB192_FURB192.py.snap index cebfe0b17f85d..fdec3718d9f27 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB192_FURB192.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB192_FURB192.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB192.py:3:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence | 1 | # Errors -2 | +2 | 3 | sorted(l)[0] | ^^^^^^^^^^^^ FURB192 -4 | +4 | 5 | sorted(l)[-1] | = help: Replace with `min` @@ -25,10 +24,10 @@ FURB192.py:3:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum FURB192.py:5:1: FURB192 [*] Prefer `max` over `sorted()` to compute the maximum value in a sequence | 3 | sorted(l)[0] -4 | +4 | 5 | sorted(l)[-1] | ^^^^^^^^^^^^^ FURB192 -6 | +6 | 7 | sorted(l, reverse=False)[-1] | = help: Replace with `max` @@ -46,10 +45,10 @@ FURB192.py:5:1: FURB192 [*] Prefer `max` over `sorted()` to compute the maximum FURB192.py:7:1: FURB192 [*] Prefer `max` over `sorted()` to compute the maximum value in a sequence | 5 | sorted(l)[-1] -6 | +6 | 7 | sorted(l, reverse=False)[-1] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB192 -8 | +8 | 9 | sorted(l, key=lambda x: x)[0] | = help: Replace with `max` @@ -67,10 +66,10 @@ FURB192.py:7:1: FURB192 [*] Prefer `max` over `sorted()` to compute the maximum FURB192.py:9:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence | 7 | sorted(l, reverse=False)[-1] - 8 | + 8 | 9 | sorted(l, key=lambda x: x)[0] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB192 -10 | +10 | 11 | sorted(l, key=key_fn)[0] | = help: Replace with `min` @@ -88,10 +87,10 @@ FURB192.py:9:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum FURB192.py:11:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence | 9 | sorted(l, key=lambda x: x)[0] -10 | +10 | 11 | sorted(l, key=key_fn)[0] | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB192 -12 | +12 | 13 | sorted([1, 2, 3])[0] | = help: Replace with `min` @@ -109,10 +108,10 @@ FURB192.py:11:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum FURB192.py:13:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence | 11 | sorted(l, key=key_fn)[0] -12 | +12 | 13 | sorted([1, 2, 3])[0] | ^^^^^^^^^^^^^^^^^^^^ FURB192 -14 | +14 | 15 | # Unsafe | = help: Replace with `min` @@ -130,10 +129,10 @@ FURB192.py:13:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum FURB192.py:17:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence | 15 | # Unsafe -16 | +16 | 17 | sorted(l, key=key_fn, reverse=True)[-1] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB192 -18 | +18 | 19 | sorted(l, reverse=True)[0] | = help: Replace with `min` @@ -151,10 +150,10 @@ FURB192.py:17:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum FURB192.py:19:1: FURB192 [*] Prefer `max` over `sorted()` to compute the maximum value in a sequence | 17 | sorted(l, key=key_fn, reverse=True)[-1] -18 | +18 | 19 | sorted(l, reverse=True)[0] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB192 -20 | +20 | 21 | sorted(l, reverse=True)[-1] | = help: Replace with `max` @@ -172,10 +171,10 @@ FURB192.py:19:1: FURB192 [*] Prefer `max` over `sorted()` to compute the maximum FURB192.py:21:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence | 19 | sorted(l, reverse=True)[0] -20 | +20 | 21 | sorted(l, reverse=True)[-1] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB192 -22 | +22 | 23 | # Non-errors | = help: Replace with `min` diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF005_RUF005.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF005_RUF005.py.snap index a4251d40e3922..14b7c0d3632bc 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF005_RUF005.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF005_RUF005.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF005.py:4:1: RUF005 Consider `[*foo]` instead of concatenation | @@ -173,7 +172,7 @@ RUF005.py:47:16: RUF005 [*] Consider `("we all feel", *Fun.words)` instead of co 46 | excitement = ("we all think",) + Fun().yay() 47 | astonishment = ("we all feel",) + Fun.words | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 -48 | +48 | 49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) | = help: Replace with `("we all feel", *Fun.words)` @@ -191,10 +190,10 @@ RUF005.py:47:16: RUF005 [*] Consider `("we all feel", *Fun.words)` instead of co RUF005.py:49:9: RUF005 [*] Consider iterable unpacking instead of concatenation | 47 | astonishment = ("we all feel",) + Fun.words -48 | +48 | 49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 -50 | +50 | 51 | baz = () + zoob | = help: Replace with iterable unpacking @@ -212,10 +211,10 @@ RUF005.py:49:9: RUF005 [*] Consider iterable unpacking instead of concatenation RUF005.py:49:39: RUF005 [*] Consider `("yes", "no", "pants", *zoob)` instead of concatenation | 47 | astonishment = ("we all feel",) + Fun.words -48 | +48 | 49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 -50 | +50 | 51 | baz = () + zoob | = help: Replace with `("yes", "no", "pants", *zoob)` @@ -233,10 +232,10 @@ RUF005.py:49:39: RUF005 [*] Consider `("yes", "no", "pants", *zoob)` instead of RUF005.py:51:7: RUF005 [*] Consider `(*zoob,)` instead of concatenation | 49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) -50 | +50 | 51 | baz = () + zoob | ^^^^^^^^^ RUF005 -52 | +52 | 53 | [] + foo + [ | = help: Replace with `(*zoob,)` @@ -254,11 +253,11 @@ RUF005.py:51:7: RUF005 [*] Consider `(*zoob,)` instead of concatenation RUF005.py:53:1: RUF005 [*] Consider `[*foo]` instead of concatenation | 51 | baz = () + zoob -52 | +52 | 53 | / [] + foo + [ 54 | | ] | |_^ RUF005 -55 | +55 | 56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] | = help: Replace with `[*foo]` @@ -277,7 +276,7 @@ RUF005.py:53:1: RUF005 [*] Consider `[*foo]` instead of concatenation RUF005.py:56:15: RUF005 [*] Consider `[sys.executable, "-m", "pylint", *args, path]` instead of concatenation | 54 | ] -55 | +55 | 56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) @@ -320,7 +319,7 @@ RUF005.py:58:5: RUF005 [*] Consider `[*a, 2, 3, 4]` instead of concatenation 57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) 58 | b = a + [2, 3] + [4] | ^^^^^^^^^^^^^^^^ RUF005 -59 | +59 | 60 | # Uses the non-preferred quote style, which should be retained. | = help: Replace with `[*a, 2, 3, 4]` @@ -340,7 +339,7 @@ RUF005.py:61:4: RUF005 [*] Consider `[*a(), 'b']` instead of concatenation 60 | # Uses the non-preferred quote style, which should be retained. 61 | f"{a() + ['b']}" | ^^^^^^^^^^^ RUF005 -62 | +62 | 63 | ### | = help: Replace with `[*a(), 'b']` diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF006_RUF006.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF006_RUF006.py.snap index 707e27a8cdf22..1df2682c60c45 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF006_RUF006.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF006_RUF006.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF006.py:6:5: RUF006 Store a reference to the return value of `asyncio.create_task` | @@ -58,7 +57,7 @@ RUF006.py:170:5: RUF006 Store a reference to the return value of `loop.create_ta 169 | loop = asyncio.new_event_loop() 170 | loop.create_task(main()) # Error | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF006 -171 | +171 | 172 | # Error | @@ -68,6 +67,6 @@ RUF006.py:175:5: RUF006 Store a reference to the return value of `loop.create_ta 174 | loop = asyncio.get_event_loop() 175 | loop.create_task(main()) # Error | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF006 -176 | +176 | 177 | # OK | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF010_RUF010.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF010_RUF010.py.snap index 969cafe0b7c90..1910bdf6f9d0e 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF010_RUF010.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF010_RUF010.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF010.py:9:4: RUF010 [*] Use explicit conversion flag | 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 | ^^^^^^^^ RUF010 -10 | +10 | 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 | = help: Replace with conversion flag @@ -25,7 +24,7 @@ RUF010.py:9:16: RUF010 [*] Use explicit conversion flag | 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 | ^^^^^^^^^ RUF010 -10 | +10 | 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 | = help: Replace with conversion flag @@ -44,7 +43,7 @@ RUF010.py:9:29: RUF010 [*] Use explicit conversion flag | 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 | ^^^^^^^^^^ RUF010 -10 | +10 | 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 | = help: Replace with conversion flag @@ -62,10 +61,10 @@ RUF010.py:9:29: RUF010 [*] Use explicit conversion flag RUF010.py:11:4: RUF010 [*] Use explicit conversion flag | 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 -10 | +10 | 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 | ^^^^^^^^^^^ RUF010 -12 | +12 | 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 | = help: Replace with conversion flag @@ -83,10 +82,10 @@ RUF010.py:11:4: RUF010 [*] Use explicit conversion flag RUF010.py:11:19: RUF010 [*] Use explicit conversion flag | 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 -10 | +10 | 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 | ^^^^^^^^^^^^ RUF010 -12 | +12 | 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 | = help: Replace with conversion flag @@ -104,10 +103,10 @@ RUF010.py:11:19: RUF010 [*] Use explicit conversion flag RUF010.py:11:35: RUF010 [*] Use explicit conversion flag | 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 -10 | +10 | 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 | ^^^^^^^^^^^^^ RUF010 -12 | +12 | 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 | = help: Replace with conversion flag @@ -125,10 +124,10 @@ RUF010.py:11:35: RUF010 [*] Use explicit conversion flag RUF010.py:13:5: RUF010 [*] Use explicit conversion flag | 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 -12 | +12 | 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 | ^^^^^^^^ RUF010 -14 | +14 | 15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 | = help: Replace with conversion flag @@ -146,10 +145,10 @@ RUF010.py:13:5: RUF010 [*] Use explicit conversion flag RUF010.py:13:19: RUF010 [*] Use explicit conversion flag | 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 -12 | +12 | 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 | ^^^^^^^^^ RUF010 -14 | +14 | 15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 | = help: Replace with conversion flag @@ -167,10 +166,10 @@ RUF010.py:13:19: RUF010 [*] Use explicit conversion flag RUF010.py:13:34: RUF010 [*] Use explicit conversion flag | 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 -12 | +12 | 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 | ^^^^^^^^^^ RUF010 -14 | +14 | 15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 | = help: Replace with conversion flag @@ -188,10 +187,10 @@ RUF010.py:13:34: RUF010 [*] Use explicit conversion flag RUF010.py:15:14: RUF010 [*] Use explicit conversion flag | 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 -14 | +14 | 15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 | ^^^^^^^^^ RUF010 -16 | +16 | 17 | f"{foo(bla)}" # OK | = help: Replace with conversion flag @@ -209,10 +208,10 @@ RUF010.py:15:14: RUF010 [*] Use explicit conversion flag RUF010.py:15:29: RUF010 [*] Use explicit conversion flag | 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 -14 | +14 | 15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 | ^^^^^^^^^^ RUF010 -16 | +16 | 17 | f"{foo(bla)}" # OK | = help: Replace with conversion flag diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF012_RUF012.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF012_RUF012.py.snap index 1f51bb989c05a..e52bcaa95fe41 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF012_RUF012.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF012_RUF012.py.snap @@ -1,12 +1,10 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -assertion_line: 82 -snapshot_kind: text --- RUF012.py:9:34: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` | 7 | } - 8 | + 8 | 9 | mutable_default: list[int] = [] | ^^ RUF012 10 | immutable_annotation: Sequence[int] = [] @@ -39,6 +37,6 @@ RUF012.py:89:38: RUF012 Mutable class attributes should be annotated with `typin 88 | id: int 89 | mutable_default: list[int] = [] | ^^ RUF012 -90 | +90 | 91 | from sqlmodel import SQLModel | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF015_RUF015.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF015_RUF015.py.snap index 5fbad3a710ff4..e0dcb01a6a050 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF015_RUF015.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF015_RUF015.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF015.py:4:1: RUF015 [*] Prefer `next(iter(x))` over single element slice | @@ -69,7 +68,7 @@ RUF015.py:7:1: RUF015 [*] Prefer `next(iter(x))` over single element slice 6 | list(i for i in x)[0] 7 | [i for i in x][0] | ^^^^^^^^^^^^^^^^^ RUF015 -8 | +8 | 9 | # OK (not indexing (solely) the first element) | = help: Replace with `next(iter(x))` @@ -130,7 +129,7 @@ RUF015.py:31:1: RUF015 [*] Prefer `next((i, i + 1) for i in x)` over single elem 30 | [i for i in x if i > 5][0] 31 | [(i, i + 1) for i in x][0] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF015 -32 | +32 | 33 | # RUF015 (multiple generators) | = help: Replace with `next((i, i + 1) for i in x)` @@ -151,7 +150,7 @@ RUF015.py:35:1: RUF015 [*] Prefer `next(i + j for i in x for j in y)` over singl 34 | y = range(10) 35 | [i + j for i in x for j in y][0] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF015 -36 | +36 | 37 | # RUF015 | = help: Replace with `next(i + j for i in x for j in y)` @@ -320,7 +319,7 @@ RUF015.py:45:1: RUF015 [*] Prefer `next(iter(x.y))` over single element slice 46 | | *x.y 47 | | ][0] | |____^ RUF015 -48 | +48 | 49 | # RUF015 (multi-line) | = help: Replace with `next(iter(x.y))` @@ -347,7 +346,7 @@ RUF015.py:50:26: RUF015 [*] Prefer `next(...)` over single element slice 53 | | if isinstance(a, ast.Assign) and a.targets[0].id == "REVISION_HEADS_MAP" 54 | | ][0] | |____^ RUF015 -55 | +55 | 56 | # RUF015 (zip) | = help: Replace with `next(...)` @@ -392,7 +391,7 @@ RUF015.py:58:1: RUF015 [*] Prefer `next(zip(x, y))` over single element slice 57 | list(zip(x, y))[0] 58 | [*zip(x, y)][0] | ^^^^^^^^^^^^^^^ RUF015 -59 | +59 | 60 | # RUF015 (pop) | = help: Replace with `next(zip(x, y))` @@ -453,7 +452,7 @@ RUF015.py:63:1: RUF015 [*] Prefer `next(iter(x))` over single element slice 62 | [i for i in x].pop(0) 63 | list(i for i in x).pop(0) | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF015 -64 | +64 | 65 | # OK | = help: Replace with `next(iter(x))` diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF016_RUF016.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF016_RUF016.py.snap index 3db5a468c389a..32d0727cc8dd2 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF016_RUF016.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF016_RUF016.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF016.py:20:13: RUF016 Indexed access to type `str` uses type `str` instead of an integer or slice | @@ -16,7 +15,7 @@ RUF016.py:21:14: RUF016 Indexed access to type `str` uses type `str` instead of 20 | var = "abc"["x"] 21 | var = f"abc"["x"] | ^^^ RUF016 -22 | +22 | 23 | # Should emit for invalid access on bytes | @@ -25,7 +24,7 @@ RUF016.py:24:14: RUF016 Indexed access to type `bytes` uses type `str` instead o 23 | # Should emit for invalid access on bytes 24 | var = b"abc"["x"] | ^^^ RUF016 -25 | +25 | 26 | # Should emit for invalid access on lists and tuples | @@ -43,7 +42,7 @@ RUF016.py:28:17: RUF016 Indexed access to type `tuple` uses type `str` instead o 27 | var = [1, 2, 3]["x"] 28 | var = (1, 2, 3)["x"] | ^^^ RUF016 -29 | +29 | 30 | # Should emit for invalid access on list comprehensions | @@ -52,7 +51,7 @@ RUF016.py:31:30: RUF016 Indexed access to type `list comprehension` uses type `s 30 | # Should emit for invalid access on list comprehensions 31 | var = [x for x in range(10)]["x"] | ^^^ RUF016 -32 | +32 | 33 | # Should emit for invalid access using tuple | @@ -61,7 +60,7 @@ RUF016.py:34:13: RUF016 Indexed access to type `str` uses type `tuple` instead o 33 | # Should emit for invalid access using tuple 34 | var = "abc"[1, 2] | ^^^^ RUF016 -35 | +35 | 36 | # Should emit for invalid access using string | @@ -70,7 +69,7 @@ RUF016.py:37:14: RUF016 Indexed access to type `list` uses type `str` instead of 36 | # Should emit for invalid access using string 37 | var = [1, 2]["x"] | ^^^ RUF016 -38 | +38 | 39 | # Should emit for invalid access using float | @@ -79,7 +78,7 @@ RUF016.py:40:14: RUF016 Indexed access to type `list` uses type `float` instead 39 | # Should emit for invalid access using float 40 | var = [1, 2][0.25] | ^^^^ RUF016 -41 | +41 | 42 | # Should emit for invalid access using dict | @@ -88,7 +87,7 @@ RUF016.py:43:14: RUF016 Indexed access to type `list` uses type `dict` instead o 42 | # Should emit for invalid access using dict 43 | var = [1, 2][{"x": "y"}] | ^^^^^^^^^^ RUF016 -44 | +44 | 45 | # Should emit for invalid access using dict comp | @@ -97,7 +96,7 @@ RUF016.py:46:14: RUF016 Indexed access to type `list` uses type `dict comprehens 45 | # Should emit for invalid access using dict comp 46 | var = [1, 2][{x: "y" for x in range(2)}] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF016 -47 | +47 | 48 | # Should emit for invalid access using list | @@ -106,7 +105,7 @@ RUF016.py:49:14: RUF016 Indexed access to type `list` uses type `tuple` instead 48 | # Should emit for invalid access using list 49 | var = [1, 2][2, 3] | ^^^^ RUF016 -50 | +50 | 51 | # Should emit for invalid access using list comp | @@ -115,7 +114,7 @@ RUF016.py:52:14: RUF016 Indexed access to type `list` uses type `list comprehens 51 | # Should emit for invalid access using list comp 52 | var = [1, 2][[x for x in range(2)]] | ^^^^^^^^^^^^^^^^^^^^^ RUF016 -53 | +53 | 54 | # Should emit on invalid access using set | @@ -124,7 +123,7 @@ RUF016.py:55:14: RUF016 Indexed access to type `list` uses type `set` instead of 54 | # Should emit on invalid access using set 55 | var = [1, 2][{"x", "y"}] | ^^^^^^^^^^ RUF016 -56 | +56 | 57 | # Should emit on invalid access using set comp | @@ -133,7 +132,7 @@ RUF016.py:58:14: RUF016 Indexed access to type `list` uses type `set comprehensi 57 | # Should emit on invalid access using set comp 58 | var = [1, 2][{x for x in range(2)}] | ^^^^^^^^^^^^^^^^^^^^^ RUF016 -59 | +59 | 60 | # Should emit on invalid access using bytes | @@ -142,7 +141,7 @@ RUF016.py:61:14: RUF016 Indexed access to type `list` uses type `bytes` instead 60 | # Should emit on invalid access using bytes 61 | var = [1, 2][b"x"] | ^^^^ RUF016 -62 | +62 | 63 | # Should emit for non-integer slice start | @@ -210,7 +209,7 @@ RUF016.py:70:17: RUF016 Slice in indexed access to type `list` uses type `list c 69 | var = [1, 2, 3][{"x": x for x in range(2)}:2] 70 | var = [1, 2, 3][[x for x in range(2)]:2] | ^^^^^^^^^^^^^^^^^^^^^ RUF016 -71 | +71 | 72 | # Should emit for non-integer slice end | @@ -278,7 +277,7 @@ RUF016.py:79:19: RUF016 Slice in indexed access to type `list` uses type `list c 78 | var = [1, 2, 3][0:{"x": x for x in range(2)}] 79 | var = [1, 2, 3][0:[x for x in range(2)]] | ^^^^^^^^^^^^^^^^^^^^^ RUF016 -80 | +80 | 81 | # Should emit for non-integer slice step | @@ -346,7 +345,7 @@ RUF016.py:88:21: RUF016 Slice in indexed access to type `list` uses type `list c 87 | var = [1, 2, 3][0:1:{"x": x for x in range(2)}] 88 | var = [1, 2, 3][0:1:[x for x in range(2)]] | ^^^^^^^^^^^^^^^^^^^^^ RUF016 -89 | +89 | 90 | # Should emit for non-integer slice start and end; should emit twice with specific ranges | @@ -355,7 +354,7 @@ RUF016.py:91:17: RUF016 Slice in indexed access to type `list` uses type `str` i 90 | # Should emit for non-integer slice start and end; should emit twice with specific ranges 91 | var = [1, 2, 3]["x":"y"] | ^^^ RUF016 -92 | +92 | 93 | # Should emit once for repeated invalid access | @@ -364,7 +363,7 @@ RUF016.py:91:21: RUF016 Slice in indexed access to type `list` uses type `str` i 90 | # Should emit for non-integer slice start and end; should emit twice with specific ranges 91 | var = [1, 2, 3]["x":"y"] | ^^^ RUF016 -92 | +92 | 93 | # Should emit once for repeated invalid access | @@ -373,6 +372,6 @@ RUF016.py:94:17: RUF016 Indexed access to type `list` uses type `str` instead of 93 | # Should emit once for repeated invalid access 94 | var = [1, 2, 3]["x"]["y"]["z"] | ^^^ RUF016 -95 | +95 | 96 | # Cannot emit on invalid access using variable in index | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017_0.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017_0.py.snap index eaeb9c874dcca..71be7e5fb593b 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017_0.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017_0.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF017_0.py:5:1: RUF017 [*] Avoid quadratic list summation | @@ -110,7 +109,7 @@ RUF017_0.py:9:1: RUF017 [*] Avoid quadratic list summation 9 | / sum([[1, 2, 3], [4, 5, 6]], 10 | | []) | |_______^ RUF017 -11 | +11 | 12 | # OK | = help: Replace with `functools.reduce` @@ -135,7 +134,7 @@ RUF017_0.py:9:1: RUF017 [*] Avoid quadratic list summation RUF017_0.py:21:5: RUF017 [*] Avoid quadratic list summation | 19 | import functools, operator -20 | +20 | 21 | sum([x, y], []) | ^^^^^^^^^^^^^^^ RUF017 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF019_RUF019.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF019_RUF019.py.snap index 22702a5c5683a..24416b08b7587 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF019_RUF019.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF019_RUF019.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF019.py:3:4: RUF019 [*] Unnecessary key check before dictionary access | @@ -43,7 +42,7 @@ RUF019.py:7:4: RUF019 [*] Unnecessary key check before dictionary access RUF019.py:10:4: RUF019 [*] Unnecessary key check before dictionary access | 8 | pass - 9 | + 9 | 10 | if (k) in d and d[k]: | ^^^^^^^^^^^^^^^^^ RUF019 11 | pass @@ -63,7 +62,7 @@ RUF019.py:10:4: RUF019 [*] Unnecessary key check before dictionary access RUF019.py:13:4: RUF019 [*] Unnecessary key check before dictionary access | 11 | pass -12 | +12 | 13 | if k in d and d[(k)]: | ^^^^^^^^^^^^^^^^^ RUF019 14 | pass @@ -83,10 +82,10 @@ RUF019.py:13:4: RUF019 [*] Unnecessary key check before dictionary access RUF019.py:16:6: RUF019 [*] Unnecessary key check before dictionary access | 14 | pass -15 | +15 | 16 | not ("key" in dct and dct["key"]) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF019 -17 | +17 | 18 | bool("key" in dct and dct["key"]) | = help: Replace with `dict.get` @@ -104,10 +103,10 @@ RUF019.py:16:6: RUF019 [*] Unnecessary key check before dictionary access RUF019.py:18:6: RUF019 [*] Unnecessary key check before dictionary access | 16 | not ("key" in dct and dct["key"]) -17 | +17 | 18 | bool("key" in dct and dct["key"]) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF019 -19 | +19 | 20 | # OK | = help: Replace with `dict.get` diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF020_RUF020.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF020_RUF020.py.snap index 8163d3d72c0e1..93eccd0055449 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF020_RUF020.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF020_RUF020.py.snap @@ -4,7 +4,7 @@ source: crates/ruff_linter/src/rules/ruff/mod.rs RUF020.py:3:7: RUF020 [*] `Union[Never, T]` is equivalent to `T` | 1 | from typing import Never, NoReturn, Union -2 | +2 | 3 | Union[Never, int] | ^^^^^ RUF020 4 | Union[NoReturn, int] @@ -168,7 +168,7 @@ RUF020.py:14:12: RUF020 `Never | T` is equivalent to `T` 13 | y: (None | Never) | None 14 | z: None | (Never | None) | ^^^^^ RUF020 -15 | +15 | 16 | a: int | Never | None | = help: Remove `Never` @@ -176,7 +176,7 @@ RUF020.py:14:12: RUF020 `Never | T` is equivalent to `T` RUF020.py:16:10: RUF020 `Never | T` is equivalent to `T` | 14 | z: None | (Never | None) -15 | +15 | 16 | a: int | Never | None | ^^^^^ RUF020 17 | b: Never | Never | None diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF021_RUF021.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF021_RUF021.py.snap index 300a19e072171..5239070ff1f95 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF021_RUF021.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF021_RUF021.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF021.py:12:10: RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear | @@ -27,7 +26,7 @@ RUF021.py:13:10: RUF021 [*] Parenthesize `a and b` expressions when chaining `an 12 | x = a or b and c # RUF021: => `a or (b and c)` 13 | x = a or b and c # looooooooooooooooooooooooooooooong comment but it won't prevent an autofix | ^^^^^^^ RUF021 -14 | +14 | 15 | a, b, c = 0, 1, 2 | = help: Parenthesize the `and` subexpression @@ -47,7 +46,7 @@ RUF021.py:16:5: RUF021 [*] Parenthesize `a and b` expressions when chaining `and 15 | a, b, c = 0, 1, 2 16 | y = a and b or c # RUF021: => `(a and b) or c` | ^^^^^^^ RUF021 -17 | +17 | 18 | a, b, c, d = 1, 2, 0, 3 | = help: Parenthesize the `and` subexpression @@ -145,7 +144,7 @@ RUF021.py:35:44: RUF021 [*] Parenthesize `a and b` expressions when chaining `an 34 | # RUF021: => `a or b or c or (d and e)`: 35 | z = [a for a in range(5) if a or b or c or d and e] | ^^^^^^^ RUF021 -36 | +36 | 37 | a, b, c, d = 0, 1, 3, 0 | = help: Parenthesize the `and` subexpression @@ -165,7 +164,7 @@ RUF021.py:38:8: RUF021 [*] Parenthesize `a and b` expressions when chaining `and 37 | a, b, c, d = 0, 1, 3, 0 38 | assert not a and b or c or d # RUF021: => `(not a and b) or c or d` | ^^^^^^^^^^^ RUF021 -39 | +39 | 40 | if (not a) and b or c or d: # RUF021: => `((not a) and b) or c or d` | = help: Parenthesize the `and` subexpression @@ -183,7 +182,7 @@ RUF021.py:38:8: RUF021 [*] Parenthesize `a and b` expressions when chaining `and RUF021.py:40:4: RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear | 38 | assert not a and b or c or d # RUF021: => `(not a and b) or c or d` -39 | +39 | 40 | if (not a) and b or c or d: # RUF021: => `((not a) and b) or c or d` | ^^^^^^^^^^^^^ RUF021 41 | if (not a and b) or c or d: # OK diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF023_RUF023.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF023_RUF023.py.snap index aee3f36be6dd7..452195dad73dc 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF023_RUF023.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF023_RUF023.py.snap @@ -26,7 +26,7 @@ RUF023.py:7:17: RUF023 [*] `Klass.__slots__` is not sorted 6 | __slots__ = ["d", "c", "b", "a"] # a comment that is untouched 7 | __slots__ = ("d", "c", "b", "a") | ^^^^^^^^^^^^^^^^^^^^ RUF023 -8 | +8 | 9 | # Quoting style is retained, | = help: Apply a natural sort to `Klass.__slots__` @@ -68,7 +68,7 @@ RUF023.py:14:24: RUF023 [*] `Klass.__slots__` is not sorted 13 | # (but they are in multiline definitions) 14 | __slots__: tuple = ("b", "c", "a",) | ^^^^^^^^^^^^^^^^ RUF023 -15 | +15 | 16 | class Klass2: | = help: Apply a natural sort to `Klass.__slots__` @@ -110,7 +110,7 @@ RUF023.py:20:21: RUF023 [*] `Klass2.__slots__` is not sorted 19 | else: 20 | __slots__ = "foo3", "foo2", "foo1" # NB: an implicit tuple (without parens) | ^^^^^^^^^^^^^^^^^^^^^^ RUF023 -21 | +21 | 22 | __slots__: list[str] = ["the", "three", "little", "pigs"] | = help: Apply a natural sort to `Klass2.__slots__` @@ -128,7 +128,7 @@ RUF023.py:20:21: RUF023 [*] `Klass2.__slots__` is not sorted RUF023.py:22:28: RUF023 [*] `Klass2.__slots__` is not sorted | 20 | __slots__ = "foo3", "foo2", "foo1" # NB: an implicit tuple (without parens) -21 | +21 | 22 | __slots__: list[str] = ["the", "three", "little", "pigs"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF023 23 | __slots__ = ("parenthesized_item"), "in", ("an_unparenthesized_tuple") @@ -172,7 +172,7 @@ RUF023.py:26:17: RUF023 [*] `Klass2.__slots__` is not sorted 25 | # not alphabetical sort or "isort-style" sort 26 | __slots__ = {"aadvark237", "aadvark10092", "aadvark174", "aadvark532"} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF023 -27 | +27 | 28 | ############################ | = help: Apply a natural sort to `Klass2.__slots__` @@ -234,7 +234,7 @@ RUF023.py:40:17: RUF023 [*] `Klass3.__slots__` is not sorted 45 | | "a" 46 | | ] | |_____^ RUF023 -47 | +47 | 48 | ################################## | = help: Apply a natural sort to `Klass3.__slots__` @@ -299,7 +299,7 @@ RUF023.py:54:17: RUF023 [*] `Klass4.__slots__` is not sorted RUF023.py:64:17: RUF023 [*] `Klass4.__slots__` is not sorted | 62 | # comment7 -63 | +63 | 64 | __slots__ = [ # comment0 | _________________^ 65 | | # comment1 @@ -310,7 +310,7 @@ RUF023.py:64:17: RUF023 [*] `Klass4.__slots__` is not sorted 70 | | # comment6 71 | | ] # comment7 | |_____^ RUF023 -72 | +72 | 73 | # from cpython/Lib/pathlib/__init__.py | = help: Apply a natural sort to `Klass4.__slots__` @@ -339,7 +339,7 @@ RUF023.py:75:17: RUF023 [*] `PurePath.__slots__` is not sorted 76 | | # The `_raw_paths` slot stores unnormalized string paths. This is set 77 | | # in the `__init__()` method. 78 | | '_raw_paths', - 79 | | + 79 | | 80 | | # The `_drv`, `_root` and `_tail_cached` slots store parsed and 81 | | # normalized parts of the path. They are set when any of the `drive`, 82 | | # `root` or `_tail` properties are accessed for the first time. The @@ -348,30 +348,30 @@ RUF023.py:75:17: RUF023 [*] `PurePath.__slots__` is not sorted 85 | | # separators (i.e. it is a list of strings), and that the root and 86 | | # tail are normalized. 87 | | '_drv', '_root', '_tail_cached', - 88 | | + 88 | | 89 | | # The `_str` slot stores the string representation of the path, 90 | | # computed from the drive, root and tail when `__str__()` is called 91 | | # for the first time. It's used to implement `_str_normcase` 92 | | '_str', - 93 | | + 93 | | 94 | | # The `_str_normcase_cached` slot stores the string path with 95 | | # normalized case. It is set when the `_str_normcase` property is 96 | | # accessed for the first time. It's used to implement `__eq__()` 97 | | # `__hash__()`, and `_parts_normcase` 98 | | '_str_normcase_cached', - 99 | | + 99 | | 100 | | # The `_parts_normcase_cached` slot stores the case-normalized 101 | | # string path after splitting on path separators. It's set when the 102 | | # `_parts_normcase` property is accessed for the first time. It's used 103 | | # to implement comparison methods like `__lt__()`. 104 | | '_parts_normcase_cached', -105 | | +105 | | 106 | | # The `_hash` slot stores the hash of the case-normalized string 107 | | # path. It's set when `__hash__()` is called for the first time. 108 | | '_hash', 109 | | ) | |_____^ RUF023 -110 | +110 | 111 | # From cpython/Lib/pickletools.py | = help: Apply a natural sort to `PurePath.__slots__` @@ -439,22 +439,22 @@ RUF023.py:113:17: RUF023 [*] `ArgumentDescriptor.__slots__` is not sorted | _________________^ 114 | | # name of descriptor record, also a module global name; a string 115 | | 'name', -116 | | +116 | | 117 | | # length of argument, in bytes; an int; UP_TO_NEWLINE and 118 | | # TAKEN_FROM_ARGUMENT{1,4,8} are negative values for variable-length 119 | | # cases 120 | | 'n', -121 | | +121 | | 122 | | # a function taking a file-like object, reading this kind of argument 123 | | # from the object at the current position, advancing the current 124 | | # position by n bytes, and returning the value of the argument 125 | | 'reader', -126 | | +126 | | 127 | | # human-readable docs for this arg descriptor; a string 128 | | 'doc', 129 | | ) | |_____^ RUF023 -130 | +130 | 131 | #################################### | = help: Apply a natural sort to `ArgumentDescriptor.__slots__` @@ -494,7 +494,7 @@ RUF023.py:138:17: RUF023 `SlotUser.__slots__` is not sorted | _________________^ 139 | | 'distance': 'measured in kilometers'} | |______________________________________________________^ RUF023 -140 | +140 | 141 | class Klass5: | = help: Apply a natural sort to `SlotUser.__slots__` @@ -538,7 +538,7 @@ RUF023.py:155:17: RUF023 `Klass5.__slots__` is not sorted 154 | ) 155 | __slots__ = ("don't" "care" "about", "__slots__" "with", "concatenated" "strings") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF023 -156 | +156 | 157 | ############################################################ | = help: Apply a natural sort to `Klass5.__slots__` @@ -550,7 +550,7 @@ RUF023.py:162:17: RUF023 [*] `BezierBuilder.__slots__` is not sorted | _________________^ 163 | | 'canvas',) | |___________________________^ RUF023 -164 | +164 | 165 | class BezierBuilder2: | = help: Apply a natural sort to `BezierBuilder.__slots__` @@ -577,7 +577,7 @@ RUF023.py:166:17: RUF023 [*] `BezierBuilder2.__slots__` is not sorted | _________________^ 167 | | 'canvas' , } | |___________________________________________^ RUF023 -168 | +168 | 169 | class BezierBuilder3: | = help: Apply a natural sort to `BezierBuilder2.__slots__` @@ -602,15 +602,15 @@ RUF023.py:170:17: RUF023 [*] `BezierBuilder3.__slots__` is not sorted 170 | __slots__ = ['xp', 'yp', | _________________^ 171 | | 'canvas' -172 | | +172 | | 173 | | # very strangely placed comment -174 | | +174 | | 175 | | , -176 | | +176 | | 177 | | # another strangely placed comment 178 | | ] | |__________________^ RUF023 -179 | +179 | 180 | class BezierBuilder4: | = help: Apply a natural sort to `BezierBuilder3.__slots__` @@ -643,7 +643,7 @@ RUF023.py:181:17: RUF023 [*] `BezierBuilder4.__slots__` is not sorted 188 | | , 189 | | ) | |_____^ RUF023 -190 | +190 | 191 | __slots__ = {"foo", "bar", | = help: Apply a natural sort to `BezierBuilder4.__slots__` @@ -666,7 +666,7 @@ RUF023.py:181:17: RUF023 [*] `BezierBuilder4.__slots__` is not sorted RUF023.py:191:17: RUF023 [*] `BezierBuilder4.__slots__` is not sorted | 189 | ) -190 | +190 | 191 | __slots__ = {"foo", "bar", | _________________^ 192 | | "baz", "bingo" diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF024_RUF024.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF024_RUF024.py.snap index df1bc34856620..4c361c86398aa 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF024_RUF024.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF024_RUF024.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF024.py:9:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys` | @@ -133,7 +132,7 @@ RUF024.py:16:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromke 15 | import builtins 16 | builtins.dict.fromkeys(pierogi_fillings, dict()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF024 -17 | +17 | 18 | # Okay. | = help: Replace with comprehension diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF027_RUF027_0.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF027_RUF027_0.py.snap index f7d533bd90cbf..2973ba29309bc 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF027_RUF027_0.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF027_RUF027_0.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF027_0.py:5:7: RUF027 [*] Possible f-string without an `f` prefix | 3 | "always ignore this: {val}" -4 | +4 | 5 | print("but don't ignore this: {val}") # RUF027 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF027 | @@ -286,7 +285,7 @@ RUF027_0.py:70:18: RUF027 [*] Possible f-string without an `f` prefix 69 | last = "Appleseed" 70 | value.method("{first} {last}") # RUF027 | ^^^^^^^^^^^^^^^^ RUF027 -71 | +71 | 72 | def format_specifiers(): | = help: Add `f` prefix diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF030_RUF030.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF030_RUF030.py.snap index 04049505ec025..8b6a2c39358c2 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF030_RUF030.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF030_RUF030.py.snap @@ -7,7 +7,7 @@ RUF030.py:6:14: RUF030 [*] `print()` call in `assert` statement is likely uninte 5 | # - single StringLiteral 6 | assert True, print("This print is not intentional.") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 -7 | +7 | 8 | # Concatenated string literals | = help: Remove `print` @@ -28,7 +28,7 @@ RUF030.py:11:14: RUF030 [*] `print()` call in `assert` statement is likely unint 10 | # - single StringLiteral 11 | assert True, print("This print" " is not intentional.") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 -12 | +12 | 13 | # Positional arguments, string literals | = help: Remove `print` @@ -49,7 +49,7 @@ RUF030.py:16:14: RUF030 [*] `print()` call in `assert` statement is likely unint 15 | # - single StringLiteral concatenated with " " 16 | assert True, print("This print", "is not intentional") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 -17 | +17 | 18 | # Concatenated string literals combined with Positional arguments | = help: Remove `print` @@ -70,7 +70,7 @@ RUF030.py:21:14: RUF030 [*] `print()` call in `assert` statement is likely unint 20 | # - single stringliteral concatenated with " " only between `print` and `is` 21 | assert True, print("This " "print", "is not intentional.") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 -22 | +22 | 23 | # Positional arguments, string literals with a variable | = help: Remove `print` @@ -91,7 +91,7 @@ RUF030.py:26:14: RUF030 [*] `print()` call in `assert` statement is likely unint 25 | # - single FString concatenated with " " 26 | assert True, print("This", print.__name__, "is not intentional.") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 -27 | +27 | 28 | # Mixed brackets string literals | = help: Remove `print` @@ -112,7 +112,7 @@ RUF030.py:31:14: RUF030 [*] `print()` call in `assert` statement is likely unint 30 | # - single StringLiteral concatenated with " " 31 | assert True, print("This print", 'is not intentional', """and should be removed""") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 -32 | +32 | 33 | # Mixed brackets with other brackets inside | = help: Remove `print` @@ -133,7 +133,7 @@ RUF030.py:36:14: RUF030 [*] `print()` call in `assert` statement is likely unint 35 | # - single StringLiteral concatenated with " " and escaped brackets 36 | assert True, print("This print", 'is not "intentional"', """and "should" be 'removed'""") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 -37 | +37 | 38 | # Positional arguments, string literals with a separator | = help: Remove `print` @@ -154,7 +154,7 @@ RUF030.py:41:14: RUF030 [*] `print()` call in `assert` statement is likely unint 40 | # - single StringLiteral concatenated with "|" 41 | assert True, print("This print", "is not intentional", sep="|") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 -42 | +42 | 43 | # Positional arguments, string literals with None as separator | = help: Remove `print` @@ -175,7 +175,7 @@ RUF030.py:46:14: RUF030 [*] `print()` call in `assert` statement is likely unint 45 | # - single StringLiteral concatenated with " " 46 | assert True, print("This print", "is not intentional", sep=None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 -47 | +47 | 48 | # Positional arguments, string literals with variable as separator, needs f-string | = help: Remove `print` @@ -196,7 +196,7 @@ RUF030.py:51:14: RUF030 [*] `print()` call in `assert` statement is likely unint 50 | # - single FString concatenated with "{U00A0}" 51 | assert True, print("This print", "is not intentional", sep=U00A0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 -52 | +52 | 53 | # Unnecessary f-string | = help: Remove `print` @@ -217,7 +217,7 @@ RUF030.py:56:14: RUF030 [*] `print()` call in `assert` statement is likely unint 55 | # - single StringLiteral 56 | assert True, print(f"This f-string is just a literal.") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 -57 | +57 | 58 | # Positional arguments, string literals and f-strings | = help: Remove `print` @@ -238,7 +238,7 @@ RUF030.py:61:14: RUF030 [*] `print()` call in `assert` statement is likely unint 60 | # - single FString concatenated with " " 61 | assert True, print("This print", f"is not {'intentional':s}") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 -62 | +62 | 63 | # Positional arguments, string literals and f-strings with a separator | = help: Remove `print` @@ -259,7 +259,7 @@ RUF030.py:66:14: RUF030 [*] `print()` call in `assert` statement is likely unint 65 | # - single FString concatenated with "|" 66 | assert True, print("This print", f"is not {'intentional':s}", sep="|") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 -67 | +67 | 68 | # A single f-string | = help: Remove `print` @@ -280,7 +280,7 @@ RUF030.py:71:14: RUF030 [*] `print()` call in `assert` statement is likely unint 70 | # - single FString 71 | assert True, print(f"This print is not {'intentional':s}") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 -72 | +72 | 73 | # A single f-string with a redundant separator | = help: Remove `print` @@ -301,7 +301,7 @@ RUF030.py:76:14: RUF030 [*] `print()` call in `assert` statement is likely unint 75 | # - single FString 76 | assert True, print(f"This print is not {'intentional':s}", sep="|") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 -77 | +77 | 78 | # Complex f-string with variable as separator | = help: Remove `print` @@ -322,7 +322,7 @@ RUF030.py:83:14: RUF030 [*] `print()` call in `assert` statement is likely unint 82 | maintainer = "John Doe" 83 | assert True, print("Unreachable due to", condition, f", ask {maintainer} for advice", sep=U00A0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 -84 | +84 | 85 | # Empty print | = help: Remove `print` @@ -343,7 +343,7 @@ RUF030.py:88:14: RUF030 [*] `print()` call in `assert` statement is likely unint 87 | # - `msg` entirely removed from assertion 88 | assert True, print() | ^^^^^^^ RUF030 -89 | +89 | 90 | # Empty print with separator | = help: Remove `print` @@ -364,7 +364,7 @@ RUF030.py:93:14: RUF030 [*] `print()` call in `assert` statement is likely unint 92 | # - `msg` entirely removed from assertion 93 | assert True, print(sep=" ") | ^^^^^^^^^^^^^^ RUF030 -94 | +94 | 95 | # Custom print function that actually returns a string | = help: Remove `print` diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF031_RUF031.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF031_RUF031.py.snap index 68f0960074856..3c1b4128b75e6 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF031_RUF031.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF031_RUF031.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF031.py:2:3: RUF031 [*] Avoid parentheses for tuples in subscripts | @@ -177,7 +176,7 @@ RUF031.py:36:3: RUF031 [*] Avoid parentheses for tuples in subscripts 35 | # https://github.com/astral-sh/ruff/issues/12776 36 | d[(*foo,bar)] | ^^^^^^^^^^ RUF031 -37 | +37 | 38 | x: dict[str, int] # tuples inside type annotations should never be altered | = help: Remove parentheses diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF032_RUF032.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF032_RUF032.py.snap index 626a673032889..98e940a88a912 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF032_RUF032.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF032_RUF032.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF032.py:6:17: RUF032 [*] `Decimal()` called with float literal argument | 4 | decimal.Decimal(0) -5 | +5 | 6 | decimal.Decimal(0.0) # Should error | ^^^ RUF032 -7 | +7 | 8 | decimal.Decimal("0.0") | = help: Replace with string literal @@ -26,10 +25,10 @@ RUF032.py:6:17: RUF032 [*] `Decimal()` called with float literal argument RUF032.py:12:17: RUF032 [*] `Decimal()` called with float literal argument | 10 | decimal.Decimal(10) -11 | +11 | 12 | decimal.Decimal(10.0) # Should error | ^^^^ RUF032 -13 | +13 | 14 | decimal.Decimal("10.0") | = help: Replace with string literal @@ -47,10 +46,10 @@ RUF032.py:12:17: RUF032 [*] `Decimal()` called with float literal argument RUF032.py:18:17: RUF032 [*] `Decimal()` called with float literal argument | 16 | decimal.Decimal(-10) -17 | +17 | 18 | decimal.Decimal(-10.0) # Should error | ^^^^^ RUF032 -19 | +19 | 20 | decimal.Decimal("-10.0") | = help: Replace with string literal @@ -68,10 +67,10 @@ RUF032.py:18:17: RUF032 [*] `Decimal()` called with float literal argument RUF032.py:33:15: RUF032 [*] `Decimal()` called with float literal argument | 31 | val = Decimal(0) -32 | +32 | 33 | val = Decimal(0.0) # Should error | ^^^ RUF032 -34 | +34 | 35 | val = Decimal("0.0") | = help: Replace with string literal @@ -89,10 +88,10 @@ RUF032.py:33:15: RUF032 [*] `Decimal()` called with float literal argument RUF032.py:39:15: RUF032 [*] `Decimal()` called with float literal argument | 37 | val = Decimal(10) -38 | +38 | 39 | val = Decimal(10.0) # Should error | ^^^^ RUF032 -40 | +40 | 41 | val = Decimal("10.0") | = help: Replace with string literal @@ -110,10 +109,10 @@ RUF032.py:39:15: RUF032 [*] `Decimal()` called with float literal argument RUF032.py:45:15: RUF032 [*] `Decimal()` called with float literal argument | 43 | val = Decimal(-10) -44 | +44 | 45 | val = Decimal(-10.0) # Should error | ^^^^^ RUF032 -46 | +46 | 47 | val = Decimal("-10.0") | = help: Replace with string literal @@ -131,10 +130,10 @@ RUF032.py:45:15: RUF032 [*] `Decimal()` called with float literal argument RUF032.py:56:15: RUF032 [*] `Decimal()` called with float literal argument | 54 | val = Decimal(~4.0) # Skip -55 | +55 | 56 | val = Decimal(++4.0) # Suggest `Decimal("4.0")` | ^^^^^ RUF032 -57 | +57 | 58 | val = Decimal(-+--++--4.0) # Suggest `Decimal("-4.0")` | = help: Replace with string literal @@ -152,7 +151,7 @@ RUF032.py:56:15: RUF032 [*] `Decimal()` called with float literal argument RUF032.py:58:15: RUF032 [*] `Decimal()` called with float literal argument | 56 | val = Decimal(++4.0) # Suggest `Decimal("4.0")` -57 | +57 | 58 | val = Decimal(-+--++--4.0) # Suggest `Decimal("-4.0")` | ^^^^^^^^^^^ RUF032 | @@ -171,10 +170,10 @@ RUF032.py:58:15: RUF032 [*] `Decimal()` called with float literal argument RUF032.py:88:23: RUF032 [*] `Decimal()` called with float literal argument | 86 | # Retest with fully qualified import -87 | +87 | 88 | val = decimal.Decimal(0.0) # Should error | ^^^ RUF032 -89 | +89 | 90 | val = decimal.Decimal("0.0") | = help: Replace with string literal @@ -192,10 +191,10 @@ RUF032.py:88:23: RUF032 [*] `Decimal()` called with float literal argument RUF032.py:92:23: RUF032 [*] `Decimal()` called with float literal argument | 90 | val = decimal.Decimal("0.0") -91 | +91 | 92 | val = decimal.Decimal(10.0) # Should error | ^^^^ RUF032 -93 | +93 | 94 | val = decimal.Decimal("10.0") | = help: Replace with string literal @@ -213,10 +212,10 @@ RUF032.py:92:23: RUF032 [*] `Decimal()` called with float literal argument RUF032.py:96:23: RUF032 [*] `Decimal()` called with float literal argument | 94 | val = decimal.Decimal("10.0") -95 | +95 | 96 | val = decimal.Decimal(-10.0) # Should error | ^^^^^ RUF032 -97 | +97 | 98 | val = decimal.Decimal("-10.0") | = help: Replace with string literal diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF033_RUF033.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF033_RUF033.py.snap index fe62f6c9157f6..073ab755a901c 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF033_RUF033.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF033_RUF033.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF033.py:19:35: RUF033 `__post_init__` method with argument defaults | 17 | baz: InitVar[int] = 1 -18 | +18 | 19 | def __post_init__(self, bar = 11, baz = 11) -> None: ... | ^^ RUF033 | @@ -14,7 +13,7 @@ RUF033.py:19:35: RUF033 `__post_init__` method with argument defaults RUF033.py:19:45: RUF033 `__post_init__` method with argument defaults | 17 | baz: InitVar[int] = 1 -18 | +18 | 19 | def __post_init__(self, bar = 11, baz = 11) -> None: ... | ^^ RUF033 | @@ -103,7 +102,7 @@ RUF033.py:46:78: RUF033 [*] `__post_init__` method with argument defaults RUF033.py:59:40: RUF033 [*] `__post_init__` method with argument defaults | 57 | ping = "pong" -58 | +58 | 59 | def __post_init__(self, bar: int = 11, baz: int = 12) -> None: ... | ^^ RUF033 | @@ -123,7 +122,7 @@ RUF033.py:59:40: RUF033 [*] `__post_init__` method with argument defaults RUF033.py:59:55: RUF033 [*] `__post_init__` method with argument defaults | 57 | ping = "pong" -58 | +58 | 59 | def __post_init__(self, bar: int = 11, baz: int = 12) -> None: ... | ^^ RUF033 | @@ -143,7 +142,7 @@ RUF033.py:59:55: RUF033 [*] `__post_init__` method with argument defaults RUF033.py:67:40: RUF033 `__post_init__` method with argument defaults | 65 | bar = "should've used attrs" -66 | +66 | 67 | def __post_init__(self, bar: str = "ahhh", baz: str = "hmm") -> None: ... | ^^^^^^ RUF033 | @@ -152,7 +151,7 @@ RUF033.py:67:40: RUF033 `__post_init__` method with argument defaults RUF033.py:67:59: RUF033 `__post_init__` method with argument defaults | 65 | bar = "should've used attrs" -66 | +66 | 67 | def __post_init__(self, bar: str = "ahhh", baz: str = "hmm") -> None: ... | ^^^^^ RUF033 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF034_RUF034.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF034_RUF034.py.snap index c045532ca5554..769e8dbce148f 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF034_RUF034.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF034_RUF034.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF034.py:5:5: RUF034 Useless `if`-`else` condition | 4 | # Invalid 5 | x = 1 if True else 1 | ^^^^^^^^^^^^^^^^ RUF034 -6 | +6 | 7 | # Invalid | @@ -16,7 +15,7 @@ RUF034.py:8:5: RUF034 Useless `if`-`else` condition 7 | # Invalid 8 | x = "a" if True else "a" | ^^^^^^^^^^^^^^^^^^^^ RUF034 - 9 | + 9 | 10 | # Invalid | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF036_RUF036.pyi.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF036_RUF036.pyi.snap index e678092721a59..64bb14120af35 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF036_RUF036.pyi.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF036_RUF036.pyi.snap @@ -1,81 +1,80 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF036.pyi:4:16: RUF036 `None` not at the end of the type annotation. | 4 | def func1(arg: None | int): ... | ^^^^ RUF036 -5 | +5 | 6 | def func2() -> None | int: ... | RUF036.pyi:6:16: RUF036 `None` not at the end of the type annotation. | 4 | def func1(arg: None | int): ... -5 | +5 | 6 | def func2() -> None | int: ... | ^^^^ RUF036 -7 | +7 | 8 | def func3(arg: None | None | int): ... | RUF036.pyi:8:16: RUF036 `None` not at the end of the type annotation. | 6 | def func2() -> None | int: ... - 7 | + 7 | 8 | def func3(arg: None | None | int): ... | ^^^^ RUF036 - 9 | + 9 | 10 | def func4(arg: U[None, int]): ... | RUF036.pyi:8:23: RUF036 `None` not at the end of the type annotation. | 6 | def func2() -> None | int: ... - 7 | + 7 | 8 | def func3(arg: None | None | int): ... | ^^^^ RUF036 - 9 | + 9 | 10 | def func4(arg: U[None, int]): ... | RUF036.pyi:10:18: RUF036 `None` not at the end of the type annotation. | 8 | def func3(arg: None | None | int): ... - 9 | + 9 | 10 | def func4(arg: U[None, int]): ... | ^^^^ RUF036 -11 | +11 | 12 | def func5() -> U[None, int]: ... | RUF036.pyi:12:18: RUF036 `None` not at the end of the type annotation. | 10 | def func4(arg: U[None, int]): ... -11 | +11 | 12 | def func5() -> U[None, int]: ... | ^^^^ RUF036 -13 | +13 | 14 | def func6(arg: U[None, None, int]): ... | RUF036.pyi:14:18: RUF036 `None` not at the end of the type annotation. | 12 | def func5() -> U[None, int]: ... -13 | +13 | 14 | def func6(arg: U[None, None, int]): ... | ^^^^ RUF036 -15 | +15 | 16 | # Ok | RUF036.pyi:14:24: RUF036 `None` not at the end of the type annotation. | 12 | def func5() -> U[None, int]: ... -13 | +13 | 14 | def func6(arg: U[None, None, int]): ... | ^^^^ RUF036 -15 | +15 | 16 | # Ok | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF038_RUF038.pyi.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF038_RUF038.pyi.snap index d6d6d902ab299..ec4ffb9e79834 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF038_RUF038.pyi.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF038_RUF038.pyi.snap @@ -5,7 +5,7 @@ RUF038.pyi:4:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` | 4 | def func1(arg1: Literal[True, False]): ... | ^^^^^^^^^^^^^^^^^^^^ RUF038 -5 | +5 | 6 | def func2(arg1: Literal[True, False, True]): ... | = help: Replace with `bool` @@ -23,10 +23,10 @@ RUF038.pyi:4:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` RUF038.pyi:6:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` | 4 | def func1(arg1: Literal[True, False]): ... -5 | +5 | 6 | def func2(arg1: Literal[True, False, True]): ... | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF038 -7 | +7 | 8 | def func3() -> Literal[True, False]: ... | = help: Replace with `bool` @@ -44,10 +44,10 @@ RUF038.pyi:6:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` RUF038.pyi:8:16: RUF038 [*] `Literal[True, False]` can be replaced with `bool` | 6 | def func2(arg1: Literal[True, False, True]): ... - 7 | + 7 | 8 | def func3() -> Literal[True, False]: ... | ^^^^^^^^^^^^^^^^^^^^ RUF038 - 9 | + 9 | 10 | def func4(arg1: Literal[True, False] | bool): ... | = help: Replace with `bool` @@ -65,10 +65,10 @@ RUF038.pyi:8:16: RUF038 [*] `Literal[True, False]` can be replaced with `bool` RUF038.pyi:10:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` | 8 | def func3() -> Literal[True, False]: ... - 9 | + 9 | 10 | def func4(arg1: Literal[True, False] | bool): ... | ^^^^^^^^^^^^^^^^^^^^ RUF038 -11 | +11 | 12 | def func5(arg1: Literal[False, True]): ... | = help: Replace with `bool` @@ -86,10 +86,10 @@ RUF038.pyi:10:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` RUF038.pyi:12:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` | 10 | def func4(arg1: Literal[True, False] | bool): ... -11 | +11 | 12 | def func5(arg1: Literal[False, True]): ... | ^^^^^^^^^^^^^^^^^^^^ RUF038 -13 | +13 | 14 | def func6(arg1: Literal[True, False, "hello", "world"]): ... | = help: Replace with `bool` @@ -107,10 +107,10 @@ RUF038.pyi:12:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` RUF038.pyi:14:17: RUF038 `Literal[True, False, ...]` can be replaced with `Literal[...] | bool` | 12 | def func5(arg1: Literal[False, True]): ... -13 | +13 | 14 | def func6(arg1: Literal[True, False, "hello", "world"]): ... | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF038 -15 | +15 | 16 | # ok | = help: Replace with `Literal[...] | bool` diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF040_RUF040.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF040_RUF040.py.snap index bbac23424e93f..4102fe32b8ffd 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF040_RUF040.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF040_RUF040.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF040.py:3:21: RUF040 Non-string literal used as assert message | @@ -8,6 +7,6 @@ RUF040.py:3:21: RUF040 Non-string literal used as assert message 2 | fruits.filter(lambda fruit: fruit.startwith("p")) 3 | assert len(fruits), 2 | ^ RUF040 -4 | +4 | 5 | assert True, "always true" | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF041_RUF041.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF041_RUF041.py.snap index 83e59df5eaf4c..d09f2bde4e621 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF041_RUF041.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF041_RUF041.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF041.py:6:4: RUF041 [*] Unnecessary nested `Literal` | @@ -136,7 +135,7 @@ RUF041.py:12:1: RUF041 [*] Unnecessary nested `Literal` 16 | | ] 17 | | ] # once | |_^ RUF041 -18 | +18 | 19 | # Ensure issue is only raised once, even on nested literals | = help: Replace with flattened `Literal` @@ -161,7 +160,7 @@ RUF041.py:20:10: RUF041 [*] Unnecessary nested `Literal` 19 | # Ensure issue is only raised once, even on nested literals 20 | MyType = Literal["foo", Literal[True, False, True], "bar"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF041 -21 | +21 | 22 | # nested literals, all equivalent to `Literal[1]` | = help: Replace with flattened `Literal` @@ -222,7 +221,7 @@ RUF041.py:25:1: RUF041 [*] Unnecessary nested `Literal` 24 | Literal[Literal[Literal[1], Literal[1]]] 25 | Literal[Literal[1], Literal[Literal[Literal[1]]]] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF041 -26 | +26 | 27 | # OK | = help: Replace with flattened `Literal` diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF041_RUF041.pyi.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF041_RUF041.pyi.snap index faf96385197dd..6b146bdc64cdb 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF041_RUF041.pyi.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF041_RUF041.pyi.snap @@ -135,7 +135,7 @@ RUF041.pyi:12:1: RUF041 [*] Unnecessary nested `Literal` 16 | | ] 17 | | ] # once | |_^ RUF041 -18 | +18 | 19 | # Ensure issue is only raised once, even on nested literals | = help: Replace with flattened `Literal` @@ -160,7 +160,7 @@ RUF041.pyi:20:10: RUF041 [*] Unnecessary nested `Literal` 19 | # Ensure issue is only raised once, even on nested literals 20 | MyType = Literal["foo", Literal[True, False, True], "bar"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF041 -21 | +21 | 22 | # nested literals, all equivalent to `Literal[1]` | = help: Replace with flattened `Literal` @@ -221,7 +221,7 @@ RUF041.pyi:25:1: RUF041 [*] Unnecessary nested `Literal` 24 | Literal[Literal[Literal[1], Literal[1]]] 25 | Literal[Literal[1], Literal[Literal[Literal[1]]]] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF041 -26 | +26 | 27 | # OK | = help: Replace with flattened `Literal` diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF052_RUF052.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF052_RUF052.py.snap index a7ceae6c47c5a..10182015077c0 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF052_RUF052.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF052_RUF052.py.snap @@ -152,7 +152,7 @@ RUF052.py:130:9: RUF052 Local dummy variable `_local` is accessed RUF052.py:138:5: RUF052 [*] Local dummy variable `_P` is accessed | 136 | from collections import namedtuple -137 | +137 | 138 | _P = ParamSpec("_P") | ^^ RUF052 139 | _T = TypeVar(name="_T", covariant=True, bound=int|str) @@ -348,7 +348,7 @@ RUF052.py:145:5: RUF052 [*] Local dummy variable `_NotADynamicClass` is accessed 144 | _DynamicClass = type("_DynamicClass", (), {}) 145 | _NotADynamicClass = type("_NotADynamicClass") | ^^^^^^^^^^^^^^^^^ RUF052 -146 | +146 | 147 | print(_T, _P, _NT, _E, _NT2, _NT3, _DynamicClass, _NotADynamicClass) | = help: Remove leading underscores diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF056_RUF056.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF056_RUF056.py.snap index 0532ef08e6a27..c269084fef655 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF056_RUF056.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF056_RUF056.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF056.py:117:43: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. | 116 | # dict.get in ternary expression 117 | value = "not found" if my_dict.get("key", False) else "default" # [RUF056] | ^^^^^ RUF056 -118 | +118 | 119 | # dict.get in an if statement | = help: Remove falsy fallback from `dict.get()` @@ -63,7 +62,7 @@ RUF056.py:124:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in RUF056.py:127:23: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. | 125 | pass -126 | +126 | 127 | if my_dict.get("key", False) or True: # [RUF056] | ^^^^^ RUF056 128 | pass @@ -85,7 +84,7 @@ RUF056.py:131:27: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 130 | # dict.get in an assert statement 131 | assert my_dict.get("key", False) # [RUF056] | ^^^^^ RUF056 -132 | +132 | 133 | # dict.get in a while statement | = help: Remove falsy fallback from `dict.get()` @@ -124,7 +123,7 @@ RUF056.py:138:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 137 | # dict.get in unary not expression 138 | value = not my_dict.get("key", False) # [RUF056] | ^^^^^ RUF056 -139 | +139 | 140 | # testing all falsy fallbacks | = help: Remove falsy fallback from `dict.get()` @@ -332,7 +331,7 @@ RUF056.py:150:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 149 | value = not my_dict.get("key", 0.0) # [RUF056] 150 | value = not my_dict.get("key", "") # [RUF056] | ^^ RUF056 -151 | +151 | 152 | # testing dict.get call using kwargs | = help: Remove falsy fallback from `dict.get()` @@ -372,7 +371,7 @@ RUF056.py:154:25: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 153 | value = not my_dict.get(key="key", default=False) # [RUF056] 154 | value = not my_dict.get(default=[], key="key") # [RUF056] | ^^^^^^^^^^ RUF056 -155 | +155 | 156 | # testing invalid dict.get call with inline comment | = help: Remove falsy fallback from `dict.get()` diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF101_RUF101_1.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF101_RUF101_1.py.snap index 101987e969d02..2b1d4b2b8b5e3 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF101_RUF101_1.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF101_RUF101_1.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF101_1.py:5:15: RUF101 [*] `TCH002` is a redirect to `TC002` | @@ -8,7 +7,7 @@ RUF101_1.py:5:15: RUF101 [*] `TCH002` is a redirect to `TC002` 4 | """ 5 | # ruff: noqa: TCH002 | ^^^^^^ RUF101 -6 | +6 | 7 | from __future__ import annotations | = help: Replace with `TC002` diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__confusables.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__confusables.snap index 2285d405cf85d..bc93398cdf9cf 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__confusables.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__confusables.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- confusables.py:1:6: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? | @@ -40,7 +39,7 @@ confusables.py:26:10: RUF001 String contains ambiguous `α` (GREEK SMALL LETTER 25 | # contains ASCII. 26 | x = "βα Bαd" | ^ RUF001 -27 | +27 | 28 | # The two characters should be flagged here. The first character is a "word" | @@ -50,7 +49,7 @@ confusables.py:31:6: RUF001 String contains ambiguous `Р` (CYRILLIC CAPITAL LET 30 | # boundary" (whitespace) that it itself ambiguous. 31 | x = "Р усский" | ^ RUF001 -32 | +32 | 33 | # Same test cases as above but using f-strings instead: | @@ -60,7 +59,7 @@ confusables.py:31:7: RUF001 String contains ambiguous ` ` (EN QUAD). Did you m 30 | # boundary" (whitespace) that it itself ambiguous. 31 | x = "Р усский" | ^ RUF001 -32 | +32 | 33 | # Same test cases as above but using f-strings instead: | @@ -88,7 +87,7 @@ confusables.py:38:7: RUF001 String contains ambiguous `Р` (CYRILLIC CAPITAL LET 37 | x = f"βα Bαd" 38 | x = f"Р усский" | ^ RUF001 -39 | +39 | 40 | # Nested f-strings | @@ -98,7 +97,7 @@ confusables.py:38:8: RUF001 String contains ambiguous ` ` (EN QUAD). Did you m 37 | x = f"βα Bαd" 38 | x = f"Р усский" | ^ RUF001 -39 | +39 | 40 | # Nested f-strings | @@ -107,7 +106,7 @@ confusables.py:41:7: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD 40 | # Nested f-strings 41 | x = f"𝐁ad string {f" {f"Р усский"}"}" | ^ RUF001 -42 | +42 | 43 | # Comments inside f-strings | @@ -116,7 +115,7 @@ confusables.py:41:21: RUF001 String contains ambiguous ` ` (EN QUAD). Did you 40 | # Nested f-strings 41 | x = f"𝐁ad string {f" {f"Р усский"}"}" | ^ RUF001 -42 | +42 | 43 | # Comments inside f-strings | @@ -125,7 +124,7 @@ confusables.py:41:25: RUF001 String contains ambiguous `Р` (CYRILLIC CAPITAL LE 40 | # Nested f-strings 41 | x = f"𝐁ad string {f" {f"Р усский"}"}" | ^ RUF001 -42 | +42 | 43 | # Comments inside f-strings | @@ -134,7 +133,7 @@ confusables.py:41:26: RUF001 String contains ambiguous ` ` (EN QUAD). Did you 40 | # Nested f-strings 41 | x = f"𝐁ad string {f" {f"Р усский"}"}" | ^ RUF001 -42 | +42 | 43 | # Comments inside f-strings | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__custom_dummy_var_regexp_preset__RUF052_RUF052.py_1.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__custom_dummy_var_regexp_preset__RUF052_RUF052.py_1.snap index a7ceae6c47c5a..10182015077c0 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__custom_dummy_var_regexp_preset__RUF052_RUF052.py_1.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__custom_dummy_var_regexp_preset__RUF052_RUF052.py_1.snap @@ -152,7 +152,7 @@ RUF052.py:130:9: RUF052 Local dummy variable `_local` is accessed RUF052.py:138:5: RUF052 [*] Local dummy variable `_P` is accessed | 136 | from collections import namedtuple -137 | +137 | 138 | _P = ParamSpec("_P") | ^^ RUF052 139 | _T = TypeVar(name="_T", covariant=True, bound=int|str) @@ -348,7 +348,7 @@ RUF052.py:145:5: RUF052 [*] Local dummy variable `_NotADynamicClass` is accessed 144 | _DynamicClass = type("_DynamicClass", (), {}) 145 | _NotADynamicClass = type("_NotADynamicClass") | ^^^^^^^^^^^^^^^^^ RUF052 -146 | +146 | 147 | print(_T, _P, _NT, _E, _NT2, _NT3, _DynamicClass, _NotADynamicClass) | = help: Remove leading underscores diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__custom_dummy_var_regexp_preset__RUF052_RUF052.py_2.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__custom_dummy_var_regexp_preset__RUF052_RUF052.py_2.snap index 8974885f86459..ad96d67d3f6fb 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__custom_dummy_var_regexp_preset__RUF052_RUF052.py_2.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__custom_dummy_var_regexp_preset__RUF052_RUF052.py_2.snap @@ -101,7 +101,7 @@ RUF052.py:130:9: RUF052 Local dummy variable `_local` is accessed RUF052.py:138:5: RUF052 Local dummy variable `_P` is accessed | 136 | from collections import namedtuple -137 | +137 | 138 | _P = ParamSpec("_P") | ^^ RUF052 139 | _T = TypeVar(name="_T", covariant=True, bound=int|str) @@ -179,7 +179,7 @@ RUF052.py:145:5: RUF052 Local dummy variable `_NotADynamicClass` is accessed 144 | _DynamicClass = type("_DynamicClass", (), {}) 145 | _NotADynamicClass = type("_NotADynamicClass") | ^^^^^^^^^^^^^^^^^ RUF052 -146 | +146 | 147 | print(_T, _P, _NT, _E, _NT2, _NT3, _DynamicClass, _NotADynamicClass) | = help: Remove leading underscores diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF039_RUF039.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF039_RUF039.py.snap index 347cf257d1747..4573c15be2319 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF039_RUF039.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF039_RUF039.py.snap @@ -123,7 +123,7 @@ RUF039.py:13:9: RUF039 First argument to `re.subn()` is not raw bytes literal 12 | re.sub(u'''nicode''', u"f(?i)rst") 13 | re.subn(b"""ytes are""", f"\u006e") | ^^^^^^^^^^^^^^^ RUF039 -14 | +14 | 15 | regex.compile('single free-spacing', flags=regex.X) | = help: Replace with raw bytes literal @@ -131,7 +131,7 @@ RUF039.py:13:9: RUF039 First argument to `re.subn()` is not raw bytes literal RUF039.py:15:15: RUF039 [*] First argument to `regex.compile()` is not raw string | 13 | re.subn(b"""ytes are""", f"\u006e") -14 | +14 | 15 | regex.compile('single free-spacing', flags=regex.X) | ^^^^^^^^^^^^^^^^^^^^^ RUF039 16 | regex.findall('si\ngle') @@ -250,7 +250,7 @@ RUF039.py:23:12: RUF039 First argument to `regex.subn()` is not raw bytes litera 22 | regex.sub(u'''nicode''', u"f(?i)rst") 23 | regex.subn(b"""ytes are""", f"\u006e") | ^^^^^^^^^^^^^^^ RUF039 -24 | +24 | 25 | regex.template("""(?m) | = help: Replace with raw bytes literal @@ -258,7 +258,7 @@ RUF039.py:23:12: RUF039 First argument to `regex.subn()` is not raw bytes litera RUF039.py:25:16: RUF039 [*] First argument to `regex.template()` is not raw string | 23 | regex.subn(b"""ytes are""", f"\u006e") -24 | +24 | 25 | regex.template("""(?m) | ________________^ 26 | | (?:ulti)? diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF043_RUF043.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF043_RUF043.py.snap index 82303fb1606fb..0207b8a58397d 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF043_RUF043.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF043_RUF043.py.snap @@ -5,7 +5,7 @@ snapshot_kind: text RUF043.py:8:43: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw | 6 | ### Errors - 7 | + 7 | 8 | with pytest.raises(FooAtTheEnd, match="foo."): ... | ^^^^^^ RUF043 9 | with pytest.raises(PackageExtraSpecifier, match="Install `foo[bar]` to enjoy all features"): ... @@ -28,7 +28,7 @@ RUF043.py:10:48: RUF043 Pattern passed to `match=` contains metacharacters but i 9 | with pytest.raises(PackageExtraSpecifier, match="Install `foo[bar]` to enjoy all features"): ... 10 | with pytest.raises(InnocentQuestion, match="Did you mean to use `Literal` instead?"): ... | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF043 -11 | +11 | 12 | with pytest.raises(StringConcatenation, match="Huh" | = help: Use a raw string or `re.escape()` to make the intention explicit @@ -36,7 +36,7 @@ RUF043.py:10:48: RUF043 Pattern passed to `match=` contains metacharacters but i RUF043.py:12:51: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw | 10 | with pytest.raises(InnocentQuestion, match="Did you mean to use `Literal` instead?"): ... -11 | +11 | 12 | with pytest.raises(StringConcatenation, match="Huh" | ___________________________________________________^ 13 | | "?"): ... @@ -51,7 +51,7 @@ RUF043.py:14:67: RUF043 Pattern passed to `match=` contains metacharacters but i 13 | "?"): ... 14 | with pytest.raises(ManuallyEscapedWindowsPathToDotFile, match="C:\\\\Users\\\\Foo\\\\.config"): ... | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF043 -15 | +15 | 16 | with pytest.raises(MiddleDot, match="foo.bar"): ... | = help: Use a raw string or `re.escape()` to make the intention explicit @@ -59,7 +59,7 @@ RUF043.py:14:67: RUF043 Pattern passed to `match=` contains metacharacters but i RUF043.py:16:41: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw | 14 | with pytest.raises(ManuallyEscapedWindowsPathToDotFile, match="C:\\\\Users\\\\Foo\\\\.config"): ... -15 | +15 | 16 | with pytest.raises(MiddleDot, match="foo.bar"): ... | ^^^^^^^^^ RUF043 17 | with pytest.raises(EndDot, match="foobar."): ... @@ -93,7 +93,7 @@ RUF043.py:19:58: RUF043 Pattern passed to `match=` contains metacharacters but i 18 | with pytest.raises(EscapedFollowedByUnescaped, match="foo\\.*bar"): ... 19 | with pytest.raises(UnescapedFollowedByEscaped, match="foo.\\*bar"): ... | ^^^^^^^^^^^^ RUF043 -20 | +20 | 21 | # https://github.com/astral-sh/ruff/issues/15316 | = help: Use a raw string or `re.escape()` to make the intention explicit @@ -109,7 +109,7 @@ RUF043.py:22:50: RUF043 Pattern passed to `match=` contains metacharacters but i RUF043.py:27:44: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw | 25 | ## Metasequences -26 | +26 | 27 | with pytest.raises(StartOfInput, match="foo\\Abar"): ... | ^^^^^^^^^^^ RUF043 28 | with pytest.raises(WordBoundary, match="foo\\bbar"): ... @@ -209,7 +209,7 @@ RUF043.py:36:42: RUF043 Pattern passed to `match=` contains metacharacters but i 35 | with pytest.raises(NonWordCharacter, match="foo\\Wbar"): ... 36 | with pytest.raises(EndOfInput, match="foo\\zbar"): ... | ^^^^^^^^^^^ RUF043 -37 | +37 | 38 | with pytest.raises(StartOfInput2, match="foobar\\A"): ... | = help: Use a raw string or `re.escape()` to make the intention explicit @@ -217,7 +217,7 @@ RUF043.py:36:42: RUF043 Pattern passed to `match=` contains metacharacters but i RUF043.py:38:45: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw | 36 | with pytest.raises(EndOfInput, match="foo\\zbar"): ... -37 | +37 | 38 | with pytest.raises(StartOfInput2, match="foobar\\A"): ... | ^^^^^^^^^^^ RUF043 39 | with pytest.raises(WordBoundary2, match="foobar\\b"): ... @@ -323,7 +323,7 @@ RUF043.py:47:43: RUF043 Pattern passed to `match=` contains metacharacters but i RUF043.py:52:42: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw | 50 | ### Acceptable false positives -51 | +51 | 52 | with pytest.raises(NameEscape, match="\\N{EN DASH}"): ... | ^^^^^^^^^^^^^^ RUF043 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF046_RUF046.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF046_RUF046.py.snap index 26d34f017ab5c..f4d9f4d4659ca 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF046_RUF046.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF046_RUF046.py.snap @@ -4,7 +4,7 @@ source: crates/ruff_linter/src/rules/ruff/mod.rs RUF046.py:10:1: RUF046 [*] Value being cast to `int` is already an integer | 8 | ### Safely fixable - 9 | + 9 | 10 | int(id()) | ^^^^^^^^^ RUF046 11 | int(len([])) @@ -89,7 +89,7 @@ RUF046.py:14:1: RUF046 [*] Value being cast to `int` is already an integer 13 | int(hash(foo, bar)) 14 | int(int('')) | ^^^^^^^^^^^^ RUF046 -15 | +15 | 16 | int(math.comb()) | = help: Remove unnecessary `int` call @@ -107,7 +107,7 @@ RUF046.py:14:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:16:1: RUF046 [*] Value being cast to `int` is already an integer | 14 | int(int('')) -15 | +15 | 16 | int(math.comb()) | ^^^^^^^^^^^^^^^^ RUF046 17 | int(math.factorial()) @@ -213,7 +213,7 @@ RUF046.py:21:1: RUF046 [*] Value being cast to `int` is already an integer 20 | int(math.isqrt()) 21 | int(math.perm()) | ^^^^^^^^^^^^^^^^ RUF046 -22 | +22 | 23 | int(round(1, 0)) | = help: Remove unnecessary `int` call @@ -231,7 +231,7 @@ RUF046.py:21:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:23:1: RUF046 [*] Value being cast to `int` is already an integer | 21 | int(math.perm()) -22 | +22 | 23 | int(round(1, 0)) | ^^^^^^^^^^^^^^^^ RUF046 24 | int(round(1, 10)) @@ -253,7 +253,7 @@ RUF046.py:24:1: RUF046 [*] Value being cast to `int` is already an integer 23 | int(round(1, 0)) 24 | int(round(1, 10)) | ^^^^^^^^^^^^^^^^^ RUF046 -25 | +25 | 26 | int(round(1)) | = help: Remove unnecessary `int` call @@ -271,7 +271,7 @@ RUF046.py:24:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:26:1: RUF046 [*] Value being cast to `int` is already an integer | 24 | int(round(1, 10)) -25 | +25 | 26 | int(round(1)) | ^^^^^^^^^^^^^ RUF046 27 | int(round(1, None)) @@ -293,7 +293,7 @@ RUF046.py:27:1: RUF046 [*] Value being cast to `int` is already an integer 26 | int(round(1)) 27 | int(round(1, None)) | ^^^^^^^^^^^^^^^^^^^ RUF046 -28 | +28 | 29 | int(round(1.)) | = help: Remove unnecessary `int` call @@ -311,7 +311,7 @@ RUF046.py:27:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:29:1: RUF046 [*] Value being cast to `int` is already an integer | 27 | int(round(1, None)) -28 | +28 | 29 | int(round(1.)) | ^^^^^^^^^^^^^^ RUF046 30 | int(round(1., None)) @@ -333,7 +333,7 @@ RUF046.py:30:1: RUF046 [*] Value being cast to `int` is already an integer 29 | int(round(1.)) 30 | int(round(1., None)) | ^^^^^^^^^^^^^^^^^^^^ RUF046 -31 | +31 | 32 | int(1) | = help: Remove unnecessary `int` call @@ -351,7 +351,7 @@ RUF046.py:30:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:32:1: RUF046 [*] Value being cast to `int` is already an integer | 30 | int(round(1., None)) -31 | +31 | 32 | int(1) | ^^^^^^ RUF046 33 | int(v := 1) @@ -436,7 +436,7 @@ RUF046.py:36:1: RUF046 [*] Value being cast to `int` is already an integer 35 | int(-1) 36 | int(+1) | ^^^^^^^ RUF046 -37 | +37 | 38 | int(1 + 1) | = help: Remove unnecessary `int` call @@ -454,7 +454,7 @@ RUF046.py:36:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:38:1: RUF046 [*] Value being cast to `int` is already an integer | 36 | int(+1) -37 | +37 | 38 | int(1 + 1) | ^^^^^^^^^^ RUF046 39 | int(1 - 1) @@ -665,7 +665,7 @@ RUF046.py:48:1: RUF046 [*] Value being cast to `int` is already an integer 47 | int(1 & 1) 48 | int(1 // 1) | ^^^^^^^^^^^ RUF046 -49 | +49 | 50 | int(1 if ... else 2) | = help: Remove unnecessary `int` call @@ -683,10 +683,10 @@ RUF046.py:48:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:50:1: RUF046 [*] Value being cast to `int` is already an integer | 48 | int(1 // 1) -49 | +49 | 50 | int(1 if ... else 2) | ^^^^^^^^^^^^^^^^^^^^ RUF046 -51 | +51 | 52 | int(1 and 0) | = help: Remove unnecessary `int` call @@ -704,7 +704,7 @@ RUF046.py:50:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:52:1: RUF046 [*] Value being cast to `int` is already an integer | 50 | int(1 if ... else 2) -51 | +51 | 52 | int(1 and 0) | ^^^^^^^^^^^^ RUF046 53 | int(0 or -1) @@ -760,7 +760,7 @@ RUF046.py:56:4: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:62:1: RUF046 [*] Value being cast to `int` is already an integer | 60 | ### Unsafe -61 | +61 | 62 | int(math.ceil()) | ^^^^^^^^^^^^^^^^ RUF046 63 | int(math.floor()) @@ -803,7 +803,7 @@ RUF046.py:64:1: RUF046 [*] Value being cast to `int` is already an integer 63 | int(math.floor()) 64 | int(math.trunc()) | ^^^^^^^^^^^^^^^^^ RUF046 -65 | +65 | 66 | int(round(inferred_int, 0)) | = help: Remove unnecessary `int` call @@ -821,7 +821,7 @@ RUF046.py:64:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:66:1: RUF046 [*] Value being cast to `int` is already an integer | 64 | int(math.trunc()) -65 | +65 | 66 | int(round(inferred_int, 0)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF046 67 | int(round(inferred_int, 10)) @@ -843,7 +843,7 @@ RUF046.py:67:1: RUF046 [*] Value being cast to `int` is already an integer 66 | int(round(inferred_int, 0)) 67 | int(round(inferred_int, 10)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF046 -68 | +68 | 69 | int(round(inferred_int)) | = help: Remove unnecessary `int` call @@ -861,7 +861,7 @@ RUF046.py:67:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:69:1: RUF046 [*] Value being cast to `int` is already an integer | 67 | int(round(inferred_int, 10)) -68 | +68 | 69 | int(round(inferred_int)) | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF046 70 | int(round(inferred_int, None)) @@ -883,7 +883,7 @@ RUF046.py:70:1: RUF046 [*] Value being cast to `int` is already an integer 69 | int(round(inferred_int)) 70 | int(round(inferred_int, None)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF046 -71 | +71 | 72 | int(round(inferred_float)) | = help: Remove unnecessary `int` call @@ -901,7 +901,7 @@ RUF046.py:70:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:72:1: RUF046 [*] Value being cast to `int` is already an integer | 70 | int(round(inferred_int, None)) -71 | +71 | 72 | int(round(inferred_float)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF046 73 | int(round(inferred_float, None)) @@ -923,7 +923,7 @@ RUF046.py:73:1: RUF046 [*] Value being cast to `int` is already an integer 72 | int(round(inferred_float)) 73 | int(round(inferred_float, None)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF046 -74 | +74 | 75 | int(round(unknown)) | = help: Remove unnecessary `int` call @@ -941,7 +941,7 @@ RUF046.py:73:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:75:1: RUF046 [*] Value being cast to `int` is already an integer | 73 | int(round(inferred_float, None)) -74 | +74 | 75 | int(round(unknown)) | ^^^^^^^^^^^^^^^^^^^ RUF046 76 | int(round(unknown, None)) @@ -979,11 +979,11 @@ RUF046.py:76:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:158:1: RUF046 [*] Value being cast to `int` is already an integer | 156 | int(1. if ... else .2) -157 | +157 | 158 | / int(1 + 159 | | 1) | |______^ RUF046 -160 | +160 | 161 | int(round(1, | = help: Remove unnecessary `int` call @@ -1001,11 +1001,11 @@ RUF046.py:158:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:161:1: RUF046 [*] Value being cast to `int` is already an integer | 159 | 1) -160 | +160 | 161 | / int(round(1, 162 | | 0)) | |_____________^ RUF046 -163 | +163 | 164 | # function calls may need to retain parentheses | = help: Remove unnecessary `int` call @@ -1029,7 +1029,7 @@ RUF046.py:168:1: RUF046 [*] Value being cast to `int` is already an integer 168 | / int(round 169 | | (1)) | |____^ RUF046 -170 | +170 | 171 | int(round # a comment | = help: Remove unnecessary `int` call @@ -1047,13 +1047,13 @@ RUF046.py:168:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:171:1: RUF046 [*] Value being cast to `int` is already an integer | 169 | (1)) -170 | +170 | 171 | / int(round # a comment 172 | | # and another comment 173 | | (10) 174 | | ) | |_^ RUF046 -175 | +175 | 176 | int(round (17)) # this is safe without parens | = help: Remove unnecessary `int` call @@ -1075,10 +1075,10 @@ RUF046.py:171:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:176:1: RUF046 [*] Value being cast to `int` is already an integer | 174 | ) -175 | +175 | 176 | int(round (17)) # this is safe without parens | ^^^^^^^^^^^^^^^ RUF046 -177 | +177 | 178 | int( round ( | = help: Remove unnecessary `int` call @@ -1096,12 +1096,12 @@ RUF046.py:176:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:178:1: RUF046 [*] Value being cast to `int` is already an integer | 176 | int(round (17)) # this is safe without parens -177 | +177 | 178 | / int( round ( 179 | | 17 180 | | )) # this is also safe without parens | |______________^ RUF046 -181 | +181 | 182 | int((round) # Comment | = help: Remove unnecessary `int` call @@ -1122,12 +1122,12 @@ RUF046.py:178:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:182:1: RUF046 [*] Value being cast to `int` is already an integer | 180 | )) # this is also safe without parens -181 | +181 | 182 | / int((round) # Comment 183 | | (42) 184 | | ) | |_^ RUF046 -185 | +185 | 186 | int((round # Comment | = help: Remove unnecessary `int` call @@ -1148,12 +1148,12 @@ RUF046.py:182:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:186:1: RUF046 [*] Value being cast to `int` is already an integer | 184 | ) -185 | +185 | 186 | / int((round # Comment 187 | | )(42) 188 | | ) | |_^ RUF046 -189 | +189 | 190 | int( # Unsafe fix because of this comment | = help: Remove unnecessary `int` call @@ -1173,7 +1173,7 @@ RUF046.py:186:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:190:1: RUF046 [*] Value being cast to `int` is already an integer | 188 | ) -189 | +189 | 190 | / int( # Unsafe fix because of this comment 191 | | ( # Comment 192 | | (round @@ -1181,7 +1181,7 @@ RUF046.py:190:1: RUF046 [*] Value being cast to `int` is already an integer 194 | | )(42) 195 | | ) | |_^ RUF046 -196 | +196 | 197 | int( | = help: Remove unnecessary `int` call @@ -1203,14 +1203,14 @@ RUF046.py:190:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:197:1: RUF046 [*] Value being cast to `int` is already an integer | 195 | ) -196 | +196 | 197 | / int( 198 | | round( 199 | | 42 200 | | ) # unsafe fix because of this comment 201 | | ) | |_^ RUF046 -202 | +202 | 203 | int( | = help: Remove unnecessary `int` call @@ -1233,7 +1233,7 @@ RUF046.py:197:1: RUF046 [*] Value being cast to `int` is already an integer RUF046.py:203:1: RUF046 [*] Value being cast to `int` is already an integer | 201 | ) -202 | +202 | 203 | / int( 204 | | round( 205 | | 42 diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF048_RUF048.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF048_RUF048.py.snap index fe1dcd4691fb4..94348d436371c 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF048_RUF048.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF048_RUF048.py.snap @@ -13,7 +13,7 @@ RUF048.py:5:6: RUF048 `__version__` may contain non-integral-like elements 4 | tuple(map(int, __version__.split("."))) 5 | list(map(int, __version__.split("."))) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF048 -6 | +6 | 7 | # `sep` passed as keyword argument | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF048_RUF048_1.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF048_RUF048_1.py.snap index a78add9e5d36b..ae6ce29c4e4db 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF048_RUF048_1.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF048_RUF048_1.py.snap @@ -33,7 +33,7 @@ RUF048_1.py:8:6: RUF048 `__version__` may contain non-integral-like elements 7 | tuple(map(int, bar.__version__.split("."))) 8 | list(map(int, bar.__version__.split("."))) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF048 - 9 | + 9 | 10 | # `sep` passed as keyword argument | @@ -48,7 +48,7 @@ RUF048_1.py:11:13: RUF048 `__version__` may contain non-integral-like elements RUF048_1.py:14:13: RUF048 `__version__` may contain non-integral-like elements | 12 | print(part) -13 | +13 | 14 | for part in map(int, __version__.split(sep=".")): | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF048 15 | print(part) diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF049_RUF049.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF049_RUF049.py.snap index 6641c9bc2bb1a..a2189975df299 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF049_RUF049.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF049_RUF049.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF049.py:10:1: RUF049 An enum class should not be decorated with `@dataclass` | 8 | ## Errors - 9 | + 9 | 10 | @dataclass | ^^^^^^^^^^ RUF049 11 | class E(Enum): ... diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_0.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_0.py.snap index 21fe4c34f83cd..fc63097a619b7 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_0.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_0.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF055_0.py:6:1: RUF055 [*] Plain string pattern passed to `re` function | @@ -86,7 +85,7 @@ RUF055_0.py:39:1: RUF055 [*] Plain string pattern passed to `re` function 38 | # this should be replaced with s.split("abc") 39 | re.split("abc", s) | ^^^^^^^^^^^^^^^^^^ RUF055 -40 | +40 | 41 | # these currently should not be modified because the patterns contain regex | = help: Replace with `s.split("abc")` @@ -112,7 +111,7 @@ RUF055_0.py:71:1: RUF055 [*] Plain string pattern passed to `re` function 76 | | s, # string 77 | | ) | |_^ RUF055 -78 | +78 | 79 | # A diagnostic should not be emitted for `sub` replacements with backreferences or | = help: Replace with `s.replace("abc", "")` @@ -190,14 +189,14 @@ RUF055_0.py:92:1: RUF055 Plain string pattern passed to `re` function 91 | re.sub(r"a", "\a", "a") 92 | re.sub(r"a", r"\a", "a") | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF055 -93 | +93 | 94 | re.sub(r"a", "\?", "a") | RUF055_0.py:94:1: RUF055 [*] Plain string pattern passed to `re` function | 92 | re.sub(r"a", r"\a", "a") -93 | +93 | 94 | re.sub(r"a", "\?", "a") | ^^^^^^^^^^^^^^^^^^^^^^^ RUF055 95 | re.sub(r"a", r"\?", "a") diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_1.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_1.py.snap index c9c05238b731b..ce467029180b0 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_1.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_1.py.snap @@ -4,10 +4,10 @@ source: crates/ruff_linter/src/rules/ruff/mod.rs RUF055_1.py:9:1: RUF055 [*] Plain string pattern passed to `re` function | 7 | pat1 = "needle" - 8 | + 8 | 9 | re.sub(pat1, "", haystack) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF055 -10 | +10 | 11 | # aliases are not followed, so this one should not trigger the rule | = help: Replace with `haystack.replace(pat1, "")` diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview_confusables.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview_confusables.snap index d6f6e62a288e7..582ef1bac4a85 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview_confusables.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview_confusables.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- confusables.py:1:6: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? | @@ -40,7 +39,7 @@ confusables.py:26:10: RUF001 String contains ambiguous `α` (GREEK SMALL LETTER 25 | # contains ASCII. 26 | x = "βα Bαd" | ^ RUF001 -27 | +27 | 28 | # The two characters should be flagged here. The first character is a "word" | @@ -50,7 +49,7 @@ confusables.py:31:6: RUF001 String contains ambiguous `Р` (CYRILLIC CAPITAL LET 30 | # boundary" (whitespace) that it itself ambiguous. 31 | x = "Р усский" | ^ RUF001 -32 | +32 | 33 | # Same test cases as above but using f-strings instead: | @@ -60,7 +59,7 @@ confusables.py:31:7: RUF001 String contains ambiguous ` ` (EN QUAD). Did you m 30 | # boundary" (whitespace) that it itself ambiguous. 31 | x = "Р усский" | ^ RUF001 -32 | +32 | 33 | # Same test cases as above but using f-strings instead: | @@ -88,7 +87,7 @@ confusables.py:38:7: RUF001 String contains ambiguous `Р` (CYRILLIC CAPITAL LET 37 | x = f"βα Bαd" 38 | x = f"Р усский" | ^ RUF001 -39 | +39 | 40 | # Nested f-strings | @@ -98,7 +97,7 @@ confusables.py:38:8: RUF001 String contains ambiguous ` ` (EN QUAD). Did you m 37 | x = f"βα Bαd" 38 | x = f"Р усский" | ^ RUF001 -39 | +39 | 40 | # Nested f-strings | @@ -107,7 +106,7 @@ confusables.py:41:7: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD 40 | # Nested f-strings 41 | x = f"𝐁ad string {f" {f"Р усский"}"}" | ^ RUF001 -42 | +42 | 43 | # Comments inside f-strings | @@ -116,7 +115,7 @@ confusables.py:41:21: RUF001 String contains ambiguous ` ` (EN QUAD). Did you 40 | # Nested f-strings 41 | x = f"𝐁ad string {f" {f"Р усский"}"}" | ^ RUF001 -42 | +42 | 43 | # Comments inside f-strings | @@ -125,7 +124,7 @@ confusables.py:41:25: RUF001 String contains ambiguous `Р` (CYRILLIC CAPITAL LE 40 | # Nested f-strings 41 | x = f"𝐁ad string {f" {f"Р усский"}"}" | ^ RUF001 -42 | +42 | 43 | # Comments inside f-strings | @@ -134,7 +133,7 @@ confusables.py:41:26: RUF001 String contains ambiguous ` ` (EN QUAD). Did you 40 | # Nested f-strings 41 | x = f"𝐁ad string {f" {f"Р усский"}"}" | ^ RUF001 -42 | +42 | 43 | # Comments inside f-strings | @@ -160,7 +159,7 @@ confusables.py:55:28: RUF001 String contains ambiguous `µ` (MICRO SIGN). Did yo | 55 | assert getattr(Labware(), "µL") == 1.5 | ^ RUF001 -56 | +56 | 57 | # Implicit string concatenation | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0.snap index 5501c104759bf..b4fc07e49ec1d 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF100_0.py:9:12: RUF100 [*] Unused blanket `noqa` directive | @@ -26,7 +25,7 @@ RUF100_0.py:13:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) 12 | # Invalid 13 | d = 1 # noqa: E501 | ^^^^^^^^^^^^ RUF100 -14 | +14 | 15 | # Invalid | = help: Remove unused `noqa` directive @@ -46,7 +45,7 @@ RUF100_0.py:16:12: RUF100 [*] Unused `noqa` directive (unused: `F841`, `E501`) 15 | # Invalid 16 | d = 1 # noqa: F841, E501 | ^^^^^^^^^^^^^^^^^^ RUF100 -17 | +17 | 18 | # Invalid (and unimplemented or not enabled) | = help: Remove unused `noqa` directive @@ -66,7 +65,7 @@ RUF100_0.py:19:12: RUF100 [*] Unused `noqa` directive (unused: `F841`, `W191`; n 18 | # Invalid (and unimplemented or not enabled) 19 | d = 1 # noqa: F841, W191, F821 | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 -20 | +20 | 21 | # Invalid (but external) | = help: Remove unused `noqa` directive @@ -86,7 +85,7 @@ RUF100_0.py:22:12: RUF100 [*] Unused `noqa` directive (unused: `F841`) 21 | # Invalid (but external) 22 | d = 1 # noqa: F841, V101 | ^^^^^^^^^^^^^^^^^^ RUF100 -23 | +23 | 24 | # Invalid (but external) | = help: Remove unused `noqa` directive @@ -106,7 +105,7 @@ RUF100_0.py:25:12: RUF100 [*] Unused `noqa` directive (unknown: `V500`) 24 | # Invalid (but external) 25 | d = 1 # noqa: V500 | ^^^^^^^^^^^^ RUF100 -26 | +26 | 27 | # fmt: off | = help: Remove unused `noqa` directive @@ -127,7 +126,7 @@ RUF100_0.py:29:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) 28 | # Invalid - no space before # 29 | d = 1 # noqa: E501 | ^^^^^^^^^^^^ RUF100 -30 | +30 | 31 | # Invalid - many spaces before # | = help: Remove unused `noqa` directive @@ -184,7 +183,7 @@ RUF100_0.py:58:6: RUF100 [*] Unused `noqa` directive (unused: `F841`) 57 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 58 | """ # noqa: E501, F841 | ^^^^^^^^^^^^^^^^^^ RUF100 -59 | +59 | 60 | # Invalid | = help: Remove unused `noqa` directive @@ -204,7 +203,7 @@ RUF100_0.py:66:6: RUF100 [*] Unused `noqa` directive (unused: `E501`) 65 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. 66 | """ # noqa: E501 | ^^^^^^^^^^^^ RUF100 -67 | +67 | 68 | # Invalid | = help: Remove unused `noqa` directive @@ -224,7 +223,7 @@ RUF100_0.py:74:6: RUF100 [*] Unused blanket `noqa` directive 73 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. 74 | """ # noqa | ^^^^^^ RUF100 -75 | +75 | 76 | # Valid | = help: Remove unused `noqa` directive @@ -261,7 +260,7 @@ RUF100_0.py:88:8: F401 [*] `shelve` imported but unused RUF100_0.py:93:89: E501 Line too long (89 > 88) | 91 | print(sys.path) -92 | +92 | 93 | "shape: (6,)\nSeries: '' [duration[μs]]\n[\n\t0µs\n\t1µs\n\t2µs\n\t3µs\n\t4µs\n\t5µs\n]" # noqa: F401 | ^ E501 | @@ -269,7 +268,7 @@ RUF100_0.py:93:89: E501 Line too long (89 > 88) RUF100_0.py:93:92: RUF100 [*] Unused `noqa` directive (unused: `F401`) | 91 | print(sys.path) -92 | +92 | 93 | "shape: (6,)\nSeries: '' [duration[μs]]\n[\n\t0µs\n\t1µs\n\t2µs\n\t3µs\n\t4µs\n\t5µs\n]" # noqa: F401 | ^^^^^^^^^^^^ RUF100 | @@ -348,7 +347,7 @@ RUF100_0.py:118:12: RUF100 [*] Unused `noqa` directive (duplicated: `F841`; unkn 117 | def f(): 118 | x = 2 # noqa: F841, F841, X200 | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 -119 | +119 | 120 | y = 2 == bar # noqa: SIM300, F841, SIM300, SIM300 | = help: Remove unused `noqa` directive @@ -366,10 +365,10 @@ RUF100_0.py:118:12: RUF100 [*] Unused `noqa` directive (duplicated: `F841`; unkn RUF100_0.py:120:19: RUF100 [*] Unused `noqa` directive (duplicated: `SIM300`, `SIM300`) | 118 | x = 2 # noqa: F841, F841, X200 -119 | +119 | 120 | y = 2 == bar # noqa: SIM300, F841, SIM300, SIM300 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 -121 | +121 | 122 | z = 2 # noqa: F841 F841 F841, F841, F841 | = help: Remove unused `noqa` directive @@ -387,10 +386,10 @@ RUF100_0.py:120:19: RUF100 [*] Unused `noqa` directive (duplicated: `SIM300`, `S RUF100_0.py:122:12: RUF100 [*] Unused `noqa` directive (duplicated: `F841`, `F841`, `F841`, `F841`) | 120 | y = 2 == bar # noqa: SIM300, F841, SIM300, SIM300 -121 | +121 | 122 | z = 2 # noqa: F841 F841 F841, F841, F841 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 -123 | +123 | 124 | return | = help: Remove unused `noqa` directive diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0_prefix.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0_prefix.snap index 631a2d7a0ea98..68c0809458083 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0_prefix.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0_prefix.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF100_0.py:9:12: RUF100 [*] Unused blanket `noqa` directive | @@ -26,7 +25,7 @@ RUF100_0.py:13:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) 12 | # Invalid 13 | d = 1 # noqa: E501 | ^^^^^^^^^^^^ RUF100 -14 | +14 | 15 | # Invalid | = help: Remove unused `noqa` directive @@ -46,7 +45,7 @@ RUF100_0.py:16:12: RUF100 [*] Unused `noqa` directive (unused: `F841`, `E501`) 15 | # Invalid 16 | d = 1 # noqa: F841, E501 | ^^^^^^^^^^^^^^^^^^ RUF100 -17 | +17 | 18 | # Invalid (and unimplemented or not enabled) | = help: Remove unused `noqa` directive @@ -66,7 +65,7 @@ RUF100_0.py:19:12: RUF100 [*] Unused `noqa` directive (unused: `F841`, `W191`; n 18 | # Invalid (and unimplemented or not enabled) 19 | d = 1 # noqa: F841, W191, F821 | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 -20 | +20 | 21 | # Invalid (but external) | = help: Remove unused `noqa` directive @@ -86,7 +85,7 @@ RUF100_0.py:22:12: RUF100 [*] Unused `noqa` directive (unused: `F841`) 21 | # Invalid (but external) 22 | d = 1 # noqa: F841, V101 | ^^^^^^^^^^^^^^^^^^ RUF100 -23 | +23 | 24 | # Invalid (but external) | = help: Remove unused `noqa` directive @@ -107,7 +106,7 @@ RUF100_0.py:29:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) 28 | # Invalid - no space before # 29 | d = 1 # noqa: E501 | ^^^^^^^^^^^^ RUF100 -30 | +30 | 31 | # Invalid - many spaces before # | = help: Remove unused `noqa` directive @@ -164,7 +163,7 @@ RUF100_0.py:58:6: RUF100 [*] Unused `noqa` directive (unused: `F841`) 57 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 58 | """ # noqa: E501, F841 | ^^^^^^^^^^^^^^^^^^ RUF100 -59 | +59 | 60 | # Invalid | = help: Remove unused `noqa` directive @@ -184,7 +183,7 @@ RUF100_0.py:66:6: RUF100 [*] Unused `noqa` directive (unused: `E501`) 65 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. 66 | """ # noqa: E501 | ^^^^^^^^^^^^ RUF100 -67 | +67 | 68 | # Invalid | = help: Remove unused `noqa` directive @@ -204,7 +203,7 @@ RUF100_0.py:74:6: RUF100 [*] Unused blanket `noqa` directive 73 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. 74 | """ # noqa | ^^^^^^ RUF100 -75 | +75 | 76 | # Valid | = help: Remove unused `noqa` directive @@ -241,7 +240,7 @@ RUF100_0.py:88:8: F401 [*] `shelve` imported but unused RUF100_0.py:93:89: E501 Line too long (89 > 88) | 91 | print(sys.path) -92 | +92 | 93 | "shape: (6,)\nSeries: '' [duration[μs]]\n[\n\t0µs\n\t1µs\n\t2µs\n\t3µs\n\t4µs\n\t5µs\n]" # noqa: F401 | ^ E501 | @@ -249,7 +248,7 @@ RUF100_0.py:93:89: E501 Line too long (89 > 88) RUF100_0.py:93:92: RUF100 [*] Unused `noqa` directive (unused: `F401`) | 91 | print(sys.path) -92 | +92 | 93 | "shape: (6,)\nSeries: '' [duration[μs]]\n[\n\t0µs\n\t1µs\n\t2µs\n\t3µs\n\t4µs\n\t5µs\n]" # noqa: F401 | ^^^^^^^^^^^^ RUF100 | @@ -328,7 +327,7 @@ RUF100_0.py:118:12: RUF100 [*] Unused `noqa` directive (duplicated: `F841`; unkn 117 | def f(): 118 | x = 2 # noqa: F841, F841, X200 | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 -119 | +119 | 120 | y = 2 == bar # noqa: SIM300, F841, SIM300, SIM300 | = help: Remove unused `noqa` directive @@ -346,10 +345,10 @@ RUF100_0.py:118:12: RUF100 [*] Unused `noqa` directive (duplicated: `F841`; unkn RUF100_0.py:120:19: RUF100 [*] Unused `noqa` directive (duplicated: `SIM300`, `SIM300`) | 118 | x = 2 # noqa: F841, F841, X200 -119 | +119 | 120 | y = 2 == bar # noqa: SIM300, F841, SIM300, SIM300 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 -121 | +121 | 122 | z = 2 # noqa: F841 F841 F841, F841, F841 | = help: Remove unused `noqa` directive @@ -367,10 +366,10 @@ RUF100_0.py:120:19: RUF100 [*] Unused `noqa` directive (duplicated: `SIM300`, `S RUF100_0.py:122:12: RUF100 [*] Unused `noqa` directive (duplicated: `F841`, `F841`, `F841`, `F841`) | 120 | y = 2 == bar # noqa: SIM300, F841, SIM300, SIM300 -121 | +121 | 122 | z = 2 # noqa: F841 F841 F841, F841, F841 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 -123 | +123 | 124 | return | = help: Remove unused `noqa` directive diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_3.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_3.snap index 65d1f67dbdf7a..f0918df155b84 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_3.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_3.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF100_3.py:1:1: RUF100 [*] Unused blanket `noqa` directive | @@ -142,7 +141,7 @@ RUF100_3.py:7:10: RUF100 [*] Unused blanket `noqa` directive RUF100_3.py:14:1: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) | 12 | print(a) # noqa comment -13 | +13 | 14 | # noqa: E501, F821 | ^^^^^^^^^^^^^^^^^^ RUF100 15 | # noqa: E501, F821 # comment @@ -436,7 +435,7 @@ RUF100_3.py:28:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) 27 | print(a) # noqa: E501, ,F821 comment 28 | print(a) # noqa: E501 F821 comment | ^^^^^^^^^^^^^^^^^ RUF100 -29 | +29 | 30 | print(a) # comment with unicode µ # noqa: E501 | = help: Remove unused `noqa` directive @@ -454,7 +453,7 @@ RUF100_3.py:28:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) RUF100_3.py:30:7: F821 Undefined name `a` | 28 | print(a) # noqa: E501 F821 comment -29 | +29 | 30 | print(a) # comment with unicode µ # noqa: E501 | ^ F821 31 | print(a) # comment with unicode µ # noqa: E501, F821 @@ -463,7 +462,7 @@ RUF100_3.py:30:7: F821 Undefined name `a` RUF100_3.py:30:39: RUF100 [*] Unused `noqa` directive (unused: `E501`) | 28 | print(a) # noqa: E501 F821 comment -29 | +29 | 30 | print(a) # comment with unicode µ # noqa: E501 | ^^^^^^^^^^^^ RUF100 31 | print(a) # comment with unicode µ # noqa: E501, F821 diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_5.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_5.snap index 8077bfa4ed25f..05d515713a9c7 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_5.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_5.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF100_5.py:7:5: ERA001 Found commented-out code | @@ -25,7 +24,7 @@ RUF100_5.py:11:1: ERA001 Found commented-out code | 11 | #import os # noqa: E501 | ^^^^^^^^^^^^^^^^^^^^^^^^ ERA001 -12 | +12 | 13 | def f(): | = help: Remove commented-out code @@ -43,7 +42,7 @@ RUF100_5.py:11:13: RUF100 [*] Unused `noqa` directive (unused: `E501`) | 11 | #import os # noqa: E501 | ^^^^^^^^^^^^ RUF100 -12 | +12 | 13 | def f(): | = help: Remove unused `noqa` directive @@ -64,7 +63,7 @@ RUF100_5.py:16:18: RUF100 [*] Unused `noqa` directive (non-enabled: `RET504`) 15 | # line below should autofix to `return data # fmt: skip` 16 | return data # noqa: RET504 # fmt: skip | ^^^^^^^^^^^^^^ RUF100 -17 | +17 | 18 | def f(): | = help: Remove unused `noqa` directive diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__error-instead-of-exception_TRY400.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__error-instead-of-exception_TRY400.py.snap index 03d81d83a836e..9e60594d46032 100644 --- a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__error-instead-of-exception_TRY400.py.snap +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__error-instead-of-exception_TRY400.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/tryceratops/mod.rs -snapshot_kind: text --- TRY400.py:13:9: TRY400 [*] Use `logging.exception` instead of `logging.error` | @@ -8,7 +7,7 @@ TRY400.py:13:9: TRY400 [*] Use `logging.exception` instead of `logging.error` 12 | except Exception: 13 | logging.error("Context message here") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 -14 | +14 | 15 | if True: | = help: Replace with `exception` @@ -47,7 +46,7 @@ TRY400.py:27:9: TRY400 [*] Use `logging.exception` instead of `logging.error` 26 | except Exception: 27 | logger.error("Context message here") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 -28 | +28 | 29 | if True: | = help: Replace with `exception` @@ -86,7 +85,7 @@ TRY400.py:37:9: TRY400 [*] Use `logging.exception` instead of `logging.error` 36 | except Exception: 37 | log.error("Context message here") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 -38 | +38 | 39 | if True: | = help: Replace with `exception` @@ -125,7 +124,7 @@ TRY400.py:47:9: TRY400 [*] Use `logging.exception` instead of `logging.error` 46 | except Exception: 47 | self.logger.error("Context message here") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 -48 | +48 | 49 | if True: | = help: Replace with `exception` @@ -164,7 +163,7 @@ TRY400.py:100:9: TRY400 [*] Use `logging.exception` instead of `logging.error` 99 | except Exception: 100 | error("Context message here") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 -101 | +101 | 102 | if True: | = help: Replace with `exception` diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-vanilla-class_TRY002.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-vanilla-class_TRY002.py.snap index 8bba4a062da6f..0df21137063fe 100644 --- a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-vanilla-class_TRY002.py.snap +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-vanilla-class_TRY002.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/tryceratops/mod.rs -snapshot_kind: text --- TRY002.py:13:15: TRY002 Create your own exception | @@ -8,7 +7,7 @@ TRY002.py:13:15: TRY002 Create your own exception 12 | if a == 1: 13 | raise Exception("Custom message") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY002 -14 | +14 | 15 | b = 1 | @@ -26,7 +25,7 @@ TRY002.py:37:15: TRY002 Create your own exception 36 | if a == 1: 37 | raise BaseException("Custom message") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY002 -38 | +38 | 39 | b = 1 | diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-within-try_TRY301.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-within-try_TRY301.py.snap index 3030a80d2b721..707345cf44296 100644 --- a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-within-try_TRY301.py.snap +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-within-try_TRY301.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/tryceratops/mod.rs -snapshot_kind: text --- TRY301.py:14:13: TRY301 Abstract `raise` to an inner function | @@ -8,17 +7,17 @@ TRY301.py:14:13: TRY301 Abstract `raise` to an inner function 13 | if not a: 14 | raise MyException(a) | ^^^^^^^^^^^^^^^^^^^^ TRY301 -15 | +15 | 16 | raise MyException(a) | TRY301.py:16:9: TRY301 Abstract `raise` to an inner function | 14 | raise MyException(a) -15 | +15 | 16 | raise MyException(a) | ^^^^^^^^^^^^^^^^^^^^ TRY301 -17 | +17 | 18 | try: | @@ -38,17 +37,17 @@ TRY301.py:32:13: TRY301 Abstract `raise` to an inner function 31 | if not a: 32 | raise MyException(a) | ^^^^^^^^^^^^^^^^^^^^ TRY301 -33 | +33 | 34 | raise MyException(a) | TRY301.py:34:9: TRY301 Abstract `raise` to an inner function | 32 | raise MyException(a) -33 | +33 | 34 | raise MyException(a) | ^^^^^^^^^^^^^^^^^^^^ TRY301 -35 | +35 | 36 | try: | diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__verbose-log-message_TRY401.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__verbose-log-message_TRY401.py.snap index 6999f6b92ab19..ddb8fc15bb7e9 100644 --- a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__verbose-log-message_TRY401.py.snap +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__verbose-log-message_TRY401.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/tryceratops/mod.rs -snapshot_kind: text --- TRY401.py:8:45: TRY401 Redundant exception object included in `logging.exception` call | @@ -55,7 +54,7 @@ TRY401.py:24:45: TRY401 Redundant exception object included in `logging.exceptio 23 | logger.exception(f"Found an error: {bad}") # TRY401 24 | logger.exception(f"Found an error: {bad}") # TRY401 | ^^^ TRY401 -25 | +25 | 26 | if True: | @@ -143,7 +142,7 @@ TRY401.py:93:38: TRY401 Redundant exception object included in `logging.exceptio 92 | exception(f"Found an error: {bad}") # TRY401 93 | exception(f"Found an error: {bad}") # TRY401 | ^^^ TRY401 -94 | +94 | 95 | if True: | diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__ipy_escape_command.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__ipy_escape_command.snap index 9899e6297d87c..1bf54524d923e 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__ipy_escape_command.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__ipy_escape_command.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/linter.rs -snapshot_kind: text --- ipy_escape_command.ipynb:cell 1:5:8: F401 [*] `os` imported but unused | 3 | %matplotlib inline -4 | +4 | 5 | import os | ^^ F401 -6 | +6 | 7 | _ = math.pi | = help: Remove unused import: `os` diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__vscode_language_id.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__vscode_language_id.snap index 2f0aa2ab11ad9..a8c65c981a9d5 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__vscode_language_id.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__vscode_language_id.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/linter.rs -snapshot_kind: text --- vscode_language_id.ipynb:cell 3:1:8: F401 [*] `os` imported but unused | 1 | import os | ^^ F401 -2 | +2 | 3 | print("hello world") | = help: Remove unused import: `os` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__double_starred.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__double_starred.py.snap index 346c5353a0be0..4ef425440b982 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__double_starred.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__double_starred.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/arguments/double_starred.py -snapshot_kind: text --- ## AST @@ -201,14 +200,14 @@ Module( 2 | call(** *x) 3 | call(***x) | ^^ Syntax Error: Starred expression cannot be used here -4 | +4 | 5 | call(**x := 1) | | 3 | call(***x) -4 | +4 | 5 | call(**x := 1) | ^^ Syntax Error: Expected ',', found ':=' | @@ -216,7 +215,7 @@ Module( | 3 | call(***x) -4 | +4 | 5 | call(**x := 1) | ^ Syntax Error: Positional argument cannot follow keyword argument unpacking | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_expression.py.snap index 70177d55205b1..46cb028b2a619 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_expression.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/arguments/invalid_expression.py -snapshot_kind: text --- ## AST @@ -179,14 +178,14 @@ Module( 1 | call(x + y = 1) 2 | call(x := 1 = 1) | ^^^^^^ Syntax Error: Expected a parameter name -3 | +3 | 4 | call(yield x) | | 2 | call(x := 1 = 1) -3 | +3 | 4 | call(yield x) | ^^^^^^^ Syntax Error: Yield expression cannot be used here 5 | call(yield from x) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_expression.py.snap index ed8132fa6e483..1c86ec46e3621 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_expression.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/arguments/missing_expression.py -snapshot_kind: text --- ## AST @@ -162,6 +161,6 @@ Module( 2 | call(x = ) 3 | call(*, y) | ^ Syntax Error: Expected an expression -4 | +4 | 5 | foo | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_0.py.snap index fa0a24674c149..0ea8939500055 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_0.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/arguments/unclosed_0.py -snapshot_kind: text --- ## AST @@ -69,7 +68,7 @@ Module( | 1 | call( | ^ Syntax Error: Expected ')', found newline -2 | +2 | 3 | def foo(): 4 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_1.py.snap index 1388d6761f691..af8a140c61834 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_1.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/arguments/unclosed_1.py -snapshot_kind: text --- ## AST @@ -77,7 +76,7 @@ Module( | 1 | call(x | ^ Syntax Error: Expected ')', found newline -2 | +2 | 3 | def foo(): 4 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_2.py.snap index df28c5c6dae22..d41c5727a7bab 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_2.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/arguments/unclosed_2.py -snapshot_kind: text --- ## AST @@ -77,7 +76,7 @@ Module( | 1 | call(x, | ^ Syntax Error: Expected ')', found newline -2 | +2 | 3 | def foo(): 4 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_0.py.snap index 2c0792722216d..747e1c7a79539 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_0.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/await/no_expression_0.py -snapshot_kind: text --- ## AST @@ -62,6 +61,6 @@ Module( 1 | # No expression after `await`, an expression on another line 2 | await | ^ Syntax Error: Expected an expression -3 | +3 | 4 | x + y | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_1.py.snap index 140d14011ab6e..7d67f0e7008b6 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_1.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/await/no_expression_1.py -snapshot_kind: text --- ## AST @@ -65,7 +64,7 @@ Module( 1 | # No expression after `await`, a statement on another line 2 | await | ^ Syntax Error: Expected an expression -3 | +3 | 4 | def foo(): 5 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__recover.py.snap index de33b1367355b..87c433552a4a5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__recover.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/await/recover.py -snapshot_kind: text --- ## AST @@ -249,7 +248,7 @@ Module( 4 | # Nested await 5 | await await x | ^^^^^^^ Syntax Error: Await expression cannot be used here -6 | +6 | 7 | # Starred expressions | @@ -267,7 +266,7 @@ Module( 8 | await *x 9 | await (*x) | ^^ Syntax Error: Starred expression cannot be used here -10 | +10 | 11 | # Invalid expression as per precedence | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__invalid_rhs_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__invalid_rhs_expression.py.snap index e961c326aab97..cb65ebee14364 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__invalid_rhs_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__invalid_rhs_expression.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/bin_op/invalid_rhs_expression.py -snapshot_kind: text --- ## AST @@ -104,14 +103,14 @@ Module( | 1 | x + lambda y: y | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here -2 | +2 | 3 | x - yield y | | 1 | x + lambda y: y -2 | +2 | 3 | x - yield y | ^^^^^^^ Syntax Error: Yield expression cannot be used here | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_lhs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_lhs.py.snap index cce646dc9460b..7e9d24594d17e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_lhs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_lhs.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/bin_op/missing_lhs.py -snapshot_kind: text --- ## AST @@ -58,6 +57,6 @@ Module( | 1 | / y | ^ Syntax Error: Expected a statement -2 | +2 | 3 | 1 + 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_0.py.snap index 59b52ca24ab32..9f84e4249e785 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_0.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/bin_op/missing_rhs_0.py -snapshot_kind: text --- ## AST @@ -72,6 +71,6 @@ Module( | 1 | 0 + | ^ Syntax Error: Expected an expression -2 | +2 | 3 | 1 + 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_1.py.snap index b6392a15527bd..2951642fe3f0b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_1.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/bin_op/missing_rhs_1.py -snapshot_kind: text --- ## AST @@ -100,6 +99,6 @@ Module( | 1 | 1 + 2 - 3 * | ^ Syntax Error: Expected an expression -2 | +2 | 3 | 4 + 5 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__invalid_rhs_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__invalid_rhs_expression.py.snap index 6690771f300a8..9b4a04616ca2a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__invalid_rhs_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__invalid_rhs_expression.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/bool_op/invalid_rhs_expression.py -snapshot_kind: text --- ## AST @@ -108,14 +107,14 @@ Module( | 1 | x and lambda y: y | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here -2 | +2 | 3 | x or yield y | | 1 | x and lambda y: y -2 | +2 | 3 | x or yield y | ^^^^^^^ Syntax Error: Yield expression cannot be used here | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__missing_rhs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__missing_rhs.py.snap index 16ed53c32d60d..34a82c7f26085 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__missing_rhs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__missing_rhs.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/bool_op/missing_rhs.py -snapshot_kind: text --- ## AST @@ -73,6 +72,6 @@ Module( | 1 | x and | ^ Syntax Error: Expected an expression -2 | +2 | 3 | 1 + 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_order.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_order.py.snap index bb9cf68340aeb..efd6a63b4df80 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_order.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_order.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/compare/invalid_order.py -snapshot_kind: text --- ## AST @@ -134,7 +133,7 @@ Module( | 1 | x in not y | ^^^^^ Syntax Error: Boolean 'not' expression cannot be used here -2 | +2 | 3 | # `=>` instead of `>=` | @@ -143,7 +142,7 @@ Module( 3 | # `=>` instead of `>=` 4 | x => y | ^ Syntax Error: Expected an expression -5 | +5 | 6 | # Same here as well, `not` without `in` is considered to be a unary operator | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_rhs_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_rhs_expression.py.snap index 90b9b4d764cd9..7fac7231c751e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_rhs_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_rhs_expression.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/compare/invalid_rhs_expression.py -snapshot_kind: text --- ## AST @@ -112,14 +111,14 @@ Module( | 1 | x not in lambda y: y | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here -2 | +2 | 3 | x == yield y | | 1 | x not in lambda y: y -2 | +2 | 3 | x == yield y | ^^^^^^^ Syntax Error: Yield expression cannot be used here | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_lhs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_lhs.py.snap index 8eb0e29ee0a92..755eb042a5979 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_lhs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_lhs.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/compare/missing_lhs.py -snapshot_kind: text --- ## AST @@ -58,6 +57,6 @@ Module( | 1 | > y | ^ Syntax Error: Expected a statement -2 | +2 | 3 | 1 + 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_0.py.snap index ddee94eb3219d..135f76de35938 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_0.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/compare/missing_rhs_0.py -snapshot_kind: text --- ## AST @@ -75,6 +74,6 @@ Module( | 1 | x > | ^ Syntax Error: Expected an expression -2 | +2 | 3 | 1 + 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_1.py.snap index fe3c56661cd2b..f61bcb3b89129 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_1.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/compare/missing_rhs_1.py -snapshot_kind: text --- ## AST @@ -77,7 +76,7 @@ Module( 1 | # Without the `in`, this is considered to be a unary `not` 2 | x not | ^^^ Syntax Error: Simple statements must be separated by newlines or semicolons -3 | +3 | 4 | 1 + 2 | @@ -86,6 +85,6 @@ Module( 1 | # Without the `in`, this is considered to be a unary `not` 2 | x not | ^ Syntax Error: Expected an expression -3 | +3 | 4 | 1 + 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_2.py.snap index 267e8dfd39d85..e530d30468f2e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_2.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/compare/missing_rhs_2.py -snapshot_kind: text --- ## AST @@ -75,6 +74,6 @@ Module( | 1 | x is not | ^ Syntax Error: Expected an expression -2 | +2 | 3 | 1 + 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__starred_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__starred_expression.py.snap index ac715fc3eb212..61e69b69f969f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__starred_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__starred_expression.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/compare/starred_expression.py -snapshot_kind: text --- ## AST @@ -167,14 +166,14 @@ Module( 1 | x >= *y 2 | x not in *y | ^^ Syntax Error: Starred expression cannot be used here -3 | +3 | 4 | *x < y | | 2 | x not in *y -3 | +3 | 4 | *x < y | ^^^^^ Syntax Error: Comparison expression cannot be used here 5 | *x is not y diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__comprehension.py.snap index 5316288d28a77..6d06ef0c123f9 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__comprehension.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/dict/comprehension.py -snapshot_kind: text --- ## AST @@ -749,7 +748,7 @@ Module( 4 | {x: y for call() in y} 5 | {x: y for {a, b} in y} | ^^^^^^ Syntax Error: Invalid assignment target -6 | +6 | 7 | # Invalid iter | @@ -787,7 +786,7 @@ Module( 10 | {x: y for x in yield from y} 11 | {x: y for x in lambda y: y} | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here -12 | +12 | 13 | # Invalid if | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star.py.snap index 51c5017b808d5..18f34772fa4e0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/dict/double_star.py -snapshot_kind: text --- ## AST @@ -482,7 +481,7 @@ Module( | 2 | # the ones which are higher than that. -3 | +3 | 4 | {**x := 1} | ^^ Syntax Error: Expected ',', found ':=' 5 | {a: 1, **x if True else y} @@ -492,7 +491,7 @@ Module( | 2 | # the ones which are higher than that. -3 | +3 | 4 | {**x := 1} | ^ Syntax Error: Expected ':', found '}' 5 | {a: 1, **x if True else y} diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star_comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star_comprehension.py.snap index a64d76004aea7..2cdfca37149d4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star_comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star_comprehension.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/dict/double_star_comprehension.py -snapshot_kind: text --- ## AST @@ -111,49 +110,49 @@ Module( | 2 | # it's actually a comprehension. -3 | +3 | 4 | {**x: y for x, y in data} | ^ Syntax Error: Expected an expression or a '}' -5 | +5 | 6 | # TODO(dhruvmanila): This test case fails because there's no way to represent `**y` | | 2 | # it's actually a comprehension. -3 | +3 | 4 | {**x: y for x, y in data} | ^^^ Syntax Error: Expected ':', found 'for' -5 | +5 | 6 | # TODO(dhruvmanila): This test case fails because there's no way to represent `**y` | | 2 | # it's actually a comprehension. -3 | +3 | 4 | {**x: y for x, y in data} | ^ Syntax Error: Expected ',', found name -5 | +5 | 6 | # TODO(dhruvmanila): This test case fails because there's no way to represent `**y` | | 2 | # it's actually a comprehension. -3 | +3 | 4 | {**x: y for x, y in data} | ^ Syntax Error: Expected ':', found ',' -5 | +5 | 6 | # TODO(dhruvmanila): This test case fails because there's no way to represent `**y` | | 2 | # it's actually a comprehension. -3 | +3 | 4 | {**x: y for x, y in data} | ^ Syntax Error: Expected ':', found '}' -5 | +5 | 6 | # TODO(dhruvmanila): This test case fails because there's no way to represent `**y` | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_2.py.snap index 52219b3d3794b..99ceea07ed510 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_2.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/dict/missing_closing_brace_2.py -snapshot_kind: text --- ## AST @@ -78,7 +77,7 @@ Module( | 1 | {x: 1, | ^ Syntax Error: Expected '}', found newline -2 | +2 | 3 | def foo(): 4 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_0.py.snap index 37dbfd73122d4..b3123ce9b0317 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_0.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/dict/named_expression_0.py -snapshot_kind: text --- ## AST @@ -123,19 +122,19 @@ Module( | 1 | # Unparenthesized named expression not allowed in key -2 | +2 | 3 | {x := 1: y, z := 2: a} | ^^^^^^ Syntax Error: Unparenthesized named expression cannot be used here -4 | +4 | 5 | x + y | | 1 | # Unparenthesized named expression not allowed in key -2 | +2 | 3 | {x := 1: y, z := 2: a} | ^^ Syntax Error: Expected ':', found ':=' -4 | +4 | 5 | x + y | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_1.py.snap index 8bdfa594b81f9..dd7855f8b4791 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_1.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/dict/named_expression_1.py -snapshot_kind: text --- ## AST @@ -129,39 +128,39 @@ Module( | 1 | # Unparenthesized named expression not allowed in value -2 | +2 | 3 | {x: y := 1, z: a := 2} | ^^ Syntax Error: Expected ',', found ':=' -4 | +4 | 5 | x + y | | 1 | # Unparenthesized named expression not allowed in value -2 | +2 | 3 | {x: y := 1, z: a := 2} | ^ Syntax Error: Expected ':', found ',' -4 | +4 | 5 | x + y | | 1 | # Unparenthesized named expression not allowed in value -2 | +2 | 3 | {x: y := 1, z: a := 2} | ^^ Syntax Error: Expected ',', found ':=' -4 | +4 | 5 | x + y | | 1 | # Unparenthesized named expression not allowed in value -2 | +2 | 3 | {x: y := 1, z: a := 2} | ^ Syntax Error: Expected ':', found '}' -4 | +4 | 5 | x + y | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__recover.py.snap index 33a294396e5f4..71d01983722cc 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__recover.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/dict/recover.py -snapshot_kind: text --- ## AST @@ -422,30 +421,30 @@ Module( | 1 | # Test cases for dictionary expressions where the parser recovers from a syntax error. -2 | +2 | 3 | {,} | ^ Syntax Error: Expected an expression -4 | +4 | 5 | {1: 2,,3: 4} | | 3 | {,} -4 | +4 | 5 | {1: 2,,3: 4} | ^ Syntax Error: Expected an expression or a '}' -6 | +6 | 7 | {1: 2,,} | | 5 | {1: 2,,3: 4} -6 | +6 | 7 | {1: 2,,} | ^ Syntax Error: Expected an expression or a '}' -8 | +8 | 9 | # Missing comma | @@ -454,7 +453,7 @@ Module( 9 | # Missing comma 10 | {1: 2 3: 4} | ^ Syntax Error: Expected ',', found int -11 | +11 | 12 | # No value | @@ -463,7 +462,7 @@ Module( 12 | # No value 13 | {1: } | ^ Syntax Error: Expected an expression -14 | +14 | 15 | # No value for double star unpacking | @@ -481,7 +480,7 @@ Module( 16 | {**} 17 | {x: y, **, a: b} | ^ Syntax Error: Expected an expression -18 | +18 | 19 | # This is not a double star unpacking | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_identifiers.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_identifiers.py.snap index 70cedec830687..7a4f5b3f5d643 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_identifiers.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_identifiers.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/emoji_identifiers.py -snapshot_kind: text --- ## AST @@ -89,7 +88,7 @@ Module( 2 | # comment 🐶 3 | ) | ^ Syntax Error: Expected a statement -4 | +4 | 5 | a = (🐶 + | @@ -99,7 +98,7 @@ Module( 2 | # comment 🐶 3 | ) | ^ Syntax Error: Expected a statement -4 | +4 | 5 | a = (🐶 + 6 | # comment | @@ -107,7 +106,7 @@ Module( | 3 | ) -4 | +4 | 5 | a = (🐶 + | ^^ Syntax Error: Got unexpected token 🐶 6 | # comment diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_0.py.snap index 53bcf17493e40..380694740073e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_0.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/if/missing_orelse_expr_0.py -snapshot_kind: text --- ## AST @@ -79,7 +78,7 @@ Module( 1 | # Missing orelse expression, followed by a statement 2 | x if expr else | ^ Syntax Error: Expected an expression -3 | +3 | 4 | def foo(): 5 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_1.py.snap index b3bdceb24d484..21c4bce330eef 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_1.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/if/missing_orelse_expr_1.py -snapshot_kind: text --- ## AST @@ -78,6 +77,6 @@ Module( 1 | # Missing orelse expression, followed by an expression 2 | x if expr else | ^ Syntax Error: Expected an expression -3 | +3 | 4 | 1 + 1 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_0.py.snap index 1ce6c350c0208..e621d76610c15 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_0.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/if/missing_test_expr_0.py -snapshot_kind: text --- ## AST @@ -79,7 +78,7 @@ Module( 1 | # Missing test expression, followed by a statement 2 | x if | ^ Syntax Error: Expected an expression -3 | +3 | 4 | def foo(): 5 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_1.py.snap index 493eb3ff3490a..1289e838434a5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_1.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/if/missing_test_expr_1.py -snapshot_kind: text --- ## AST @@ -78,6 +77,6 @@ Module( 1 | # Missing test expression, followed by an expression 2 | x if | ^ Syntax Error: Expected an expression -3 | +3 | 4 | 1 + 1 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__recover.py.snap index 544681b1dd8be..dd35e9a27d710 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__recover.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/if/recover.py -snapshot_kind: text --- ## AST @@ -330,7 +329,7 @@ Module( 4 | x if yield x else y 5 | x if yield from x else y | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here -6 | +6 | 7 | # Invalid orelse expression | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_duplicate_parameters.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_duplicate_parameters.py.snap index 7d90bb96bc329..04b08939f39db 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_duplicate_parameters.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_duplicate_parameters.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/lambda_duplicate_parameters.py -snapshot_kind: text --- ## AST @@ -288,44 +287,44 @@ Module( | 1 | lambda a, a: 1 | ^ Syntax Error: Duplicate parameter "a" -2 | +2 | 3 | lambda a, *, a: 1 | | 1 | lambda a, a: 1 -2 | +2 | 3 | lambda a, *, a: 1 | ^ Syntax Error: Duplicate parameter "a" -4 | +4 | 5 | lambda a, a=20: 1 | | 3 | lambda a, *, a: 1 -4 | +4 | 5 | lambda a, a=20: 1 | ^ Syntax Error: Duplicate parameter "a" -6 | +6 | 7 | lambda a, *a: 1 | | 5 | lambda a, a=20: 1 -6 | +6 | 7 | lambda a, *a: 1 | ^ Syntax Error: Duplicate parameter "a" -8 | +8 | 9 | lambda a, *, **a: 1 | | 7 | lambda a, *a: 1 -8 | +8 | 9 | lambda a, *, **a: 1 | ^^^ Syntax Error: Expected one or more keyword parameter after '*' separator | @@ -333,7 +332,7 @@ Module( | 7 | lambda a, *a: 1 -8 | +8 | 9 | lambda a, *, **a: 1 | ^ Syntax Error: Duplicate parameter "a" | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap index 55cc0ad09ca9e..124079789dd45 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/list/comprehension.py -snapshot_kind: text --- ## AST @@ -680,7 +679,7 @@ Module( 1 | # Iterable unpacking not allowed 2 | [*x for x in y] | ^^ Syntax Error: Iterable unpacking cannot be used in a comprehension -3 | +3 | 4 | # Invalid target | @@ -718,7 +717,7 @@ Module( 7 | [x for call() in y] 8 | [x for {a, b} in y] | ^^^^^^ Syntax Error: Invalid assignment target - 9 | + 9 | 10 | # Invalid iter | @@ -756,7 +755,7 @@ Module( 13 | [x for x in yield from y] 14 | [x for x in lambda y: y] | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here -15 | +15 | 16 | # Invalid if | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_3.py.snap index 31e09c2ac2d8c..9a64dd38fcd62 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_3.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/list/missing_closing_bracket_3.py -snapshot_kind: text --- ## AST @@ -75,10 +74,10 @@ Module( | 2 | # token starts a statement. -3 | +3 | 4 | [1, 2 | ^ Syntax Error: Expected ']', found newline -5 | +5 | 6 | def foo(): 7 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__recover.py.snap index ff1876c1cce4b..a3979fcf8a6da 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__recover.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/list/recover.py -snapshot_kind: text --- ## AST @@ -242,30 +241,30 @@ Module( | 1 | # Test cases for list expressions where the parser recovers from a syntax error. -2 | +2 | 3 | [,] | ^ Syntax Error: Expected an expression -4 | +4 | 5 | [1,,2] | | 3 | [,] -4 | +4 | 5 | [1,,2] | ^ Syntax Error: Expected an expression or a ']' -6 | +6 | 7 | [1,,] | | 5 | [1,,2] -6 | +6 | 7 | [1,,] | ^ Syntax Error: Expected an expression or a ']' -8 | +8 | 9 | # Missing comma | @@ -274,7 +273,7 @@ Module( 9 | # Missing comma 10 | [1 2] | ^ Syntax Error: Expected ',', found int -11 | +11 | 12 | # Dictionary element in a list | @@ -283,7 +282,7 @@ Module( 12 | # Dictionary element in a list 13 | [1: 2] | ^ Syntax Error: Expected an expression or a ']' -14 | +14 | 15 | # Missing expression | @@ -292,24 +291,24 @@ Module( 15 | # Missing expression 16 | [1, x + ] | ^ Syntax Error: Expected an expression -17 | +17 | 18 | [1; 2] | | 16 | [1, x + ] -17 | +17 | 18 | [1; 2] | ^ Syntax Error: Expected an expression or a ']' -19 | +19 | 20 | [*] | | 18 | [1; 2] -19 | +19 | 20 | [*] | ^ Syntax Error: Expected an expression | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap index 2f6b32a6ae75b..97dfb3722e30c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/list/star_expression_precedence.py -snapshot_kind: text --- ## AST @@ -394,7 +393,7 @@ Module( | 1 | # For list expression, the minimum binding power of star expression is bitwise or. -2 | +2 | 3 | [(*x), y] | ^^ Syntax Error: Starred expression cannot be used here 4 | [*x in y, z] diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__invalid_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__invalid_target.py.snap index 038635fa8decd..c10ee4aac896e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__invalid_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__invalid_target.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/named/invalid_target.py -snapshot_kind: text --- ## AST @@ -178,7 +177,7 @@ Module( | 1 | # Assignment expression target can only be an identifier -2 | +2 | 3 | (x.y := 1) | ^^^ Syntax Error: Assignment expression target must be an identifier 4 | (x[y] := 1) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_4.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_4.py.snap index 3bb178d843330..8f056e9ec54ba 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_4.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_4.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/named/missing_expression_4.py -snapshot_kind: text --- ## AST @@ -67,9 +66,9 @@ Module( | 1 | # No expression on the right side of the assignment expression -2 | +2 | 3 | (x := ) | ^ Syntax Error: Expected an expression -4 | +4 | 5 | x + y | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_3.py.snap index 091cd8c26aa46..9afe7ee6e72b1 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_3.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/parenthesized/missing_closing_paren_3.py -snapshot_kind: text --- ## AST @@ -76,10 +75,10 @@ Module( | 2 | # token starts a statement. -3 | +3 | 4 | (1, 2 | ^ Syntax Error: Expected ')', found newline -5 | +5 | 6 | def foo(): 7 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__parenthesized.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__parenthesized.py.snap index e4ede8da480ec..c61c600e25c38 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__parenthesized.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__parenthesized.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/parenthesized/parenthesized.py -snapshot_kind: text --- ## AST @@ -63,7 +62,7 @@ Module( 1 | # Starred expression isn't allowed in a parenthesized expression. 2 | (*x) | ^^ Syntax Error: Starred expression cannot be used here -3 | +3 | 4 | # Unparenthesized named expression is allowed. | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple.py.snap index 225d5bf70c13c..e62134566929b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/parenthesized/tuple.py -snapshot_kind: text --- ## AST @@ -251,30 +250,30 @@ Module( | 1 | # Test cases for tuple expressions where the parser recovers from a syntax error. -2 | +2 | 3 | (,) | ^ Syntax Error: Expected an expression -4 | +4 | 5 | (1,,2) | | 3 | (,) -4 | +4 | 5 | (1,,2) | ^ Syntax Error: Expected an expression or a ')' -6 | +6 | 7 | (1,,) | | 5 | (1,,2) -6 | +6 | 7 | (1,,) | ^ Syntax Error: Expected an expression or a ')' -8 | +8 | 9 | # Missing comma | @@ -283,7 +282,7 @@ Module( 9 | # Missing comma 10 | (1 2) | ^ Syntax Error: Expected ')', found int -11 | +11 | 12 | # Dictionary element in a list | @@ -292,7 +291,7 @@ Module( 9 | # Missing comma 10 | (1 2) | ^ Syntax Error: Expected a statement -11 | +11 | 12 | # Dictionary element in a list | @@ -301,7 +300,7 @@ Module( 9 | # Missing comma 10 | (1 2) | ^ Syntax Error: Expected a statement -11 | +11 | 12 | # Dictionary element in a list 13 | (1: 2) | @@ -311,7 +310,7 @@ Module( 12 | # Dictionary element in a list 13 | (1: 2) | ^ Syntax Error: Expected ')', found ':' -14 | +14 | 15 | # Missing expression | @@ -320,7 +319,7 @@ Module( 12 | # Dictionary element in a list 13 | (1: 2) | ^ Syntax Error: Invalid annotated assignment target -14 | +14 | 15 | # Missing expression | @@ -329,7 +328,7 @@ Module( 12 | # Dictionary element in a list 13 | (1: 2) | ^ Syntax Error: Expected a statement -14 | +14 | 15 | # Missing expression | @@ -338,7 +337,7 @@ Module( 12 | # Dictionary element in a list 13 | (1: 2) | ^ Syntax Error: Expected a statement -14 | +14 | 15 | # Missing expression 16 | (1, x + ) | @@ -348,37 +347,37 @@ Module( 15 | # Missing expression 16 | (1, x + ) | ^ Syntax Error: Expected an expression -17 | +17 | 18 | (1; 2) | | 16 | (1, x + ) -17 | +17 | 18 | (1; 2) | ^ Syntax Error: Expected ')', found ';' -19 | +19 | 20 | # Unparenthesized named expression is not allowed | | 16 | (1, x + ) -17 | +17 | 18 | (1; 2) | ^ Syntax Error: Expected a statement -19 | +19 | 20 | # Unparenthesized named expression is not allowed | | 16 | (1, x + ) -17 | +17 | 18 | (1; 2) | ^ Syntax Error: Expected a statement -19 | +19 | 20 | # Unparenthesized named expression is not allowed 21 | x, y := 2, z | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple_starred_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple_starred_expr.py.snap index 24fada07a64f7..4b75ea06edf18 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple_starred_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple_starred_expr.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/parenthesized/tuple_starred_expr.py -snapshot_kind: text --- ## AST @@ -1119,7 +1118,7 @@ Module( | 2 | # Test the first and any other element as the there are two separate calls. -3 | +3 | 4 | (*x in y, z, *x in y) | ^^^^^^ Syntax Error: Comparison expression cannot be used here 5 | (*not x, z, *not x) @@ -1129,7 +1128,7 @@ Module( | 2 | # Test the first and any other element as the there are two separate calls. -3 | +3 | 4 | (*x in y, z, *x in y) | ^^^^^^ Syntax Error: Comparison expression cannot be used here 5 | (*not x, z, *not x) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__comprehension.py.snap index 85ce25515ba3a..b692643db9843 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__comprehension.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/set/comprehension.py -snapshot_kind: text --- ## AST @@ -680,7 +679,7 @@ Module( 1 | # Iterable unpacking not allowed 2 | {*x for x in y} | ^^ Syntax Error: Iterable unpacking cannot be used in a comprehension -3 | +3 | 4 | # Invalid target | @@ -718,7 +717,7 @@ Module( 7 | {x for call() in y} 8 | {x for {a, b} in y} | ^^^^^^ Syntax Error: Invalid assignment target - 9 | + 9 | 10 | # Invalid iter | @@ -756,7 +755,7 @@ Module( 13 | {x for x in yield from y} 14 | {x for x in lambda y: y} | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here -15 | +15 | 16 | # Invalid if | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_3.py.snap index 77cac8b0286f5..f0ac8ba0d955f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_3.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/set/missing_closing_curly_brace_3.py -snapshot_kind: text --- ## AST @@ -74,10 +73,10 @@ Module( | 2 | # token starts a statement. -3 | +3 | 4 | {1, 2 | ^ Syntax Error: Expected '}', found newline -5 | +5 | 6 | def foo(): 7 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__recover.py.snap index 641af13e09b71..6df00c1bc5d31 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__recover.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/set/recover.py -snapshot_kind: text --- ## AST @@ -239,30 +238,30 @@ Module( | 3 | # These are same as for the list expressions. -4 | +4 | 5 | {,} | ^ Syntax Error: Expected an expression -6 | +6 | 7 | {1,,2} | | 5 | {,} -6 | +6 | 7 | {1,,2} | ^ Syntax Error: Expected an expression or a '}' -8 | +8 | 9 | {1,,} | | 7 | {1,,2} - 8 | + 8 | 9 | {1,,} | ^ Syntax Error: Expected an expression or a '}' -10 | +10 | 11 | # Missing comma | @@ -271,7 +270,7 @@ Module( 11 | # Missing comma 12 | {1 2} | ^ Syntax Error: Expected ',', found int -13 | +13 | 14 | # Dictionary element in a list | @@ -280,24 +279,24 @@ Module( 17 | # Missing expression 18 | {1, x + } | ^ Syntax Error: Expected an expression -19 | +19 | 20 | {1; 2} | | 18 | {1, x + } -19 | +19 | 20 | {1; 2} | ^ Syntax Error: Expected an expression or a '}' -21 | +21 | 22 | [*] | | 20 | {1; 2} -21 | +21 | 22 | [*] | ^ Syntax Error: Expected an expression | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap index 1b82f1b4704f6..5fd3b81e29e4f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/set/star_expression_precedence.py -snapshot_kind: text --- ## AST @@ -386,7 +385,7 @@ Module( | 1 | # For set expression, the minimum binding power of star expression is bitwise or. -2 | +2 | 3 | {(*x), y} | ^^ Syntax Error: Starred expression cannot be used here 4 | {*x in y, z} diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__invalid_slice_element.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__invalid_slice_element.py.snap index 40b23ecf3f757..598a1ba08e83a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__invalid_slice_element.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__invalid_slice_element.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/subscript/invalid_slice_element.py -snapshot_kind: text --- ## AST @@ -255,7 +254,7 @@ Module( | 1 | x[x := 1:] | ^^^^^^ Syntax Error: Unparenthesized named expression cannot be used here -2 | +2 | 3 | # Starred expression | @@ -283,7 +282,7 @@ Module( 5 | x[:*x] 6 | x[::*x] | ^^ Syntax Error: Starred expression cannot be used here -7 | +7 | 8 | # Empty slice | @@ -292,7 +291,7 @@ Module( 8 | # Empty slice 9 | x[] | ^ Syntax Error: Expected index or slice expression -10 | +10 | 11 | # Mixed starred expression and named expression | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_0.py.snap index b742a1c320673..3ea59b57e8614 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_0.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/unary/no_expression_0.py -snapshot_kind: text --- ## AST @@ -62,6 +61,6 @@ Module( | 1 | not | ^ Syntax Error: Expected an expression -2 | +2 | 3 | x + y | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_1.py.snap index 6a4778efd2ba6..62d13301c9fa8 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_1.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/unary/no_expression_1.py -snapshot_kind: text --- ## AST @@ -62,6 +61,6 @@ Module( | 1 | + | ^ Syntax Error: Expected an expression -2 | +2 | 3 | x + y | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__named_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__named_expression.py.snap index 41b3250f9777e..84e07f14e90b9 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__named_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__named_expression.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/yield/named_expression.py -snapshot_kind: text --- ## AST @@ -104,14 +103,14 @@ Module( 1 | # Unparenthesized named expressions are not allowed 2 | yield x := 1 | ^^ Syntax Error: Expected a statement -3 | +3 | 4 | yield 1, x := 2, 3 | | 2 | yield x := 1 -3 | +3 | 4 | yield 1, x := 2, 3 | ^^ Syntax Error: Expected ',', found ':=' | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__star_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__star_expression.py.snap index f6bf002f5665c..99a626da4e187 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__star_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__star_expression.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/yield/star_expression.py -snapshot_kind: text --- ## AST @@ -101,14 +100,14 @@ Module( 1 | # Cannot use starred expression here 2 | yield (*x) | ^^ Syntax Error: Starred expression cannot be used here -3 | +3 | 4 | yield *x and y, z | | 2 | yield (*x) -3 | +3 | 4 | yield *x and y, z | ^^^^^^^ Syntax Error: Boolean expression cannot be used here | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__starred_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__starred_expression.py.snap index 507caa1e49829..4adf70d811ce3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__starred_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__starred_expression.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/yield_from/starred_expression.py -snapshot_kind: text --- ## AST @@ -80,7 +79,7 @@ Module( | 1 | # Yield from doesn't allow top-level starred expression unlike yield -2 | +2 | 3 | yield from *x | ^^ Syntax Error: Starred expression cannot be used here 4 | yield from *x, y diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__unparenthesized.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__unparenthesized.py.snap index 6a482405dcdf5..40ffb45e66079 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__unparenthesized.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__unparenthesized.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/yield_from/unparenthesized.py -snapshot_kind: text --- ## AST @@ -137,7 +136,7 @@ Module( 1 | # Unparenthesized named expression 2 | yield from x := 1 | ^^ Syntax Error: Expected a statement -3 | +3 | 4 | # Unparenthesized tuple expression | @@ -146,7 +145,7 @@ Module( 4 | # Unparenthesized tuple expression 5 | yield from x, y | ^^^^ Syntax Error: Unparenthesized tuple expression cannot be used here -6 | +6 | 7 | # This is a tuple expression parsing | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_1.py.snap index e2bfe5cd6093d..abeaef0f131ae 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_1.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/re_lexing/line_continuation_1.py -snapshot_kind: text --- ## AST @@ -84,7 +83,7 @@ Module( | 1 | call(a, b, \\\ | ^ Syntax Error: Expected a newline after line continuation character -2 | +2 | 3 | def bar(): | @@ -92,14 +91,14 @@ Module( | 1 | call(a, b, \\\ | ^ Syntax Error: Expected a newline after line continuation character -2 | +2 | 3 | def bar(): | | 1 | call(a, b, \\\ -2 | +2 | | ^ Syntax Error: Expected ')', found newline 3 | def bar(): 4 | pass diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__function_type_parameters.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__function_type_parameters.py.snap index b1ed4a65c4e82..0c547eb7b4826 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__function_type_parameters.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__function_type_parameters.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/statements/function_type_parameters.py -snapshot_kind: text --- ## AST @@ -324,57 +323,57 @@ Module( | 9 | # on following lines. -10 | +10 | 11 | def keyword[A, await](): ... | ^^^^^ Syntax Error: Expected an identifier, but found a keyword 'await' that cannot be used here -12 | +12 | 13 | def not_a_type_param[A, |, B](): ... | | 11 | def keyword[A, await](): ... -12 | +12 | 13 | def not_a_type_param[A, |, B](): ... | ^ Syntax Error: Expected ',', found '|' -14 | +14 | 15 | def multiple_commas[A,,B](): ... | | 11 | def keyword[A, await](): ... -12 | +12 | 13 | def not_a_type_param[A, |, B](): ... | ^ Syntax Error: Expected a type parameter or the end of the type parameter list -14 | +14 | 15 | def multiple_commas[A,,B](): ... | | 13 | def not_a_type_param[A, |, B](): ... -14 | +14 | 15 | def multiple_commas[A,,B](): ... | ^ Syntax Error: Expected a type parameter or the end of the type parameter list -16 | +16 | 17 | def multiple_trailing_commas[A,,](): ... | | 15 | def multiple_commas[A,,B](): ... -16 | +16 | 17 | def multiple_trailing_commas[A,,](): ... | ^ Syntax Error: Expected a type parameter or the end of the type parameter list -18 | +18 | 19 | def multiple_commas_and_recovery[A,,100](): ... | | 17 | def multiple_trailing_commas[A,,](): ... -18 | +18 | 19 | def multiple_commas_and_recovery[A,,100](): ... | ^ Syntax Error: Expected a type parameter or the end of the type parameter list | @@ -382,7 +381,7 @@ Module( | 17 | def multiple_trailing_commas[A,,](): ... -18 | +18 | 19 | def multiple_commas_and_recovery[A,,100](): ... | ^^^ Syntax Error: Expected ']', found int | @@ -390,7 +389,7 @@ Module( | 17 | def multiple_trailing_commas[A,,](): ... -18 | +18 | 19 | def multiple_commas_and_recovery[A,,100](): ... | ^ Syntax Error: Expected newline, found ']' | @@ -398,7 +397,7 @@ Module( | 17 | def multiple_trailing_commas[A,,](): ... -18 | +18 | 19 | def multiple_commas_and_recovery[A,,100](): ... | ^^ Syntax Error: Only single target (not tuple) can be annotated | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_assignment_targets.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_assignment_targets.py.snap index c5e9b195e3e71..14d38462fb0c5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_assignment_targets.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_assignment_targets.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/statements/invalid_assignment_targets.py -snapshot_kind: text --- ## AST @@ -1383,30 +1382,30 @@ Module( | 3 | # rejected by the parser. e.g., `5 = 3`, `5 += 3`, `(5): int = 3`. -4 | +4 | 5 | 5 = 3 | ^ Syntax Error: Invalid assignment target -6 | +6 | 7 | 5 += 3 | | 5 | 5 = 3 -6 | +6 | 7 | 5 += 3 | ^ Syntax Error: Invalid augmented assignment target -8 | +8 | 9 | (5): int = 3 | | 7 | 5 += 3 - 8 | + 8 | 9 | (5): int = 3 | ^ Syntax Error: Invalid annotated assignment target -10 | +10 | 11 | # Now we exhaustively test all possible cases where assignment can fail. | @@ -1574,14 +1573,14 @@ Module( 27 | a < b < c = 42 28 | foo() = 42 | ^^^^^ Syntax Error: Invalid assignment target -29 | +29 | 30 | f"{quux}" = 42 | | 28 | foo() = 42 -29 | +29 | 30 | f"{quux}" = 42 | ^^^^^^^^^ Syntax Error: Invalid assignment target 31 | f"{foo} and {bar}" = 42 @@ -1592,14 +1591,14 @@ Module( 30 | f"{quux}" = 42 31 | f"{foo} and {bar}" = 42 | ^^^^^^^^^^^^^^^^^^ Syntax Error: Invalid assignment target -32 | +32 | 33 | "foo" = 42 | | 31 | f"{foo} and {bar}" = 42 -32 | +32 | 33 | "foo" = 42 | ^^^^^ Syntax Error: Invalid assignment target 34 | b"foo" = 42 diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_augmented_assignment_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_augmented_assignment_target.py.snap index 6602a88e64a7d..4fa30fed7b61a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_augmented_assignment_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_augmented_assignment_target.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/statements/invalid_augmented_assignment_target.py -snapshot_kind: text --- ## AST @@ -1278,7 +1277,7 @@ Module( | 2 | # assignment targets. -3 | +3 | 4 | x or y += 42 | ^^^^^^ Syntax Error: Invalid augmented assignment target 5 | (x := 5) += 42 @@ -1439,14 +1438,14 @@ Module( 19 | a < b < c += 42 20 | foo() += 42 | ^^^^^ Syntax Error: Invalid augmented assignment target -21 | +21 | 22 | f"{quux}" += 42 | | 20 | foo() += 42 -21 | +21 | 22 | f"{quux}" += 42 | ^^^^^^^^^ Syntax Error: Invalid augmented assignment target 23 | f"{foo} and {bar}" += 42 @@ -1457,14 +1456,14 @@ Module( 22 | f"{quux}" += 42 23 | f"{foo} and {bar}" += 42 | ^^^^^^^^^^^^^^^^^^ Syntax Error: Invalid augmented assignment target -24 | +24 | 25 | "foo" += 42 | | 23 | f"{foo} and {bar}" += 42 -24 | +24 | 25 | "foo" += 42 | ^^^^^ Syntax Error: Invalid augmented assignment target 26 | b"foo" += 42 diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap index 78edca9d8e0fb..e05f49c03b445 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/statements/with/ambiguous_lpar_with_items.py -snapshot_kind: text --- ## AST @@ -1362,7 +1361,7 @@ Module( | 2 | # These cases should raise the correct syntax error and recover properly. -3 | +3 | 4 | with (item1, item2),: ... | ^ Syntax Error: Trailing comma not allowed 5 | with (item1, item2), as f: ... @@ -1452,7 +1451,7 @@ Module( 11 | with (x for x in range(10), item): ... 12 | with (item, x for x in range(10)): ... | ^^^ Syntax Error: Expected ')', found 'for' -13 | +13 | 14 | # Make sure the parser doesn't report the same error twice | @@ -1462,7 +1461,7 @@ Module( 11 | with (x for x in range(10), item): ... 12 | with (item, x for x in range(10)): ... | ^ Syntax Error: Expected ':', found ')' -13 | +13 | 14 | # Make sure the parser doesn't report the same error twice | @@ -1472,7 +1471,7 @@ Module( 11 | with (x for x in range(10), item): ... 12 | with (item, x for x in range(10)): ... | ^ Syntax Error: Expected a statement -13 | +13 | 14 | # Make sure the parser doesn't report the same error twice | @@ -1481,14 +1480,14 @@ Module( 14 | # Make sure the parser doesn't report the same error twice 15 | with ((*item)): ... | ^^^^^ Syntax Error: Starred expression cannot be used here -16 | +16 | 17 | with (*x for x in iter, item): ... | | 15 | with ((*item)): ... -16 | +16 | 17 | with (*x for x in iter, item): ... | ^^ Syntax Error: Iterable unpacking cannot be used in a comprehension 18 | with (item1, *x for x in iter, item2): ... @@ -1498,7 +1497,7 @@ Module( | 15 | with ((*item)): ... -16 | +16 | 17 | with (*x for x in iter, item): ... | ^ Syntax Error: Expected ')', found ',' 18 | with (item1, *x for x in iter, item2): ... @@ -1508,7 +1507,7 @@ Module( | 15 | with ((*item)): ... -16 | +16 | 17 | with (*x for x in iter, item): ... | ^ Syntax Error: Expected ',', found ')' 18 | with (item1, *x for x in iter, item2): ... @@ -1607,7 +1606,7 @@ Module( 24 | with (x as f, y) as f: ... 25 | with (x for x in iter as y): ... | ^^ Syntax Error: Expected ')', found 'as' -26 | +26 | 27 | # The inner `(...)` is parsed as parenthesized expression | @@ -1617,7 +1616,7 @@ Module( 24 | with (x as f, y) as f: ... 25 | with (x for x in iter as y): ... | ^ Syntax Error: Expected ',', found ')' -26 | +26 | 27 | # The inner `(...)` is parsed as parenthesized expression | @@ -1626,7 +1625,7 @@ Module( 27 | # The inner `(...)` is parsed as parenthesized expression 28 | with ((item as f)): ... | ^^ Syntax Error: Expected ')', found 'as' -29 | +29 | 30 | with (item as f), x: ... | @@ -1635,7 +1634,7 @@ Module( 27 | # The inner `(...)` is parsed as parenthesized expression 28 | with ((item as f)): ... | ^ Syntax Error: Expected ':', found ')' -29 | +29 | 30 | with (item as f), x: ... | @@ -1644,14 +1643,14 @@ Module( 27 | # The inner `(...)` is parsed as parenthesized expression 28 | with ((item as f)): ... | ^ Syntax Error: Expected a statement -29 | +29 | 30 | with (item as f), x: ... | | 28 | with ((item as f)): ... -29 | +29 | 30 | with (item as f), x: ... | ^ Syntax Error: Expected ':', found ',' 31 | with (item as f1) as f2: ... diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__empty_with_items.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__empty_with_items.py.snap index 4a2405c4ffe6f..9d3a53afb0bca 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__empty_with_items.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__empty_with_items.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/statements/with/empty_with_items.py -snapshot_kind: text --- ## AST @@ -62,9 +61,9 @@ Module( | 2 | # The parser should recover from this syntax error. -3 | +3 | 4 | with : ... | ^ Syntax Error: Expected the start of an expression after `with` keyword -5 | +5 | 6 | x + y | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unparenthesized_with_items.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unparenthesized_with_items.py.snap index f0c47e83101ca..7182e64ab16f0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unparenthesized_with_items.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unparenthesized_with_items.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/statements/with/unparenthesized_with_items.py -snapshot_kind: text --- ## AST @@ -298,7 +297,7 @@ Module( | 1 | # For parenthesized with items test cases, refer to `./ambiguous_lpar_with_items.py` -2 | +2 | 3 | with item,: pass | ^ Syntax Error: Trailing comma not allowed 4 | with item as x,: pass From a71cc624e1faf8b466d595c50d51514fedf7e3c2 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Tue, 7 Jan 2025 12:16:26 -0500 Subject: [PATCH 06/18] test: update snapshots with missing annotations These updates center around the addition of annotations in the diagnostic rendering. Previously, the annotation was just not rendered at all. With the `annotate-snippets` upgrade, it is now rendered. I examined a pseudo random sample of these, and they all look correct. As will be true in future batches, some of these snapshots also have changes to whitespace in them as well. --- ...at__tests__ISC001_ISC_syntax_error.py.snap | 11 ++++++----- ...at__tests__ISC002_ISC_syntax_error.py.snap | 7 ++++--- ...kage_first_and_third_party_imports.py.snap | 2 +- ...kage_first_and_third_party_imports.py.snap | 2 +- ...tests__add_newline_before_comments.py.snap | 2 +- ..._isort__tests__as_imports_comments.py.snap | 8 ++++---- ...sts__case_sensitive_case_sensitive.py.snap | 2 +- ...to_furthest_relative_imports_order.py.snap | 2 +- ...__isort__tests__combine_as_imports.py.snap | 2 +- ...bine_as_imports_combine_as_imports.py.snap | 2 +- ..._isort__tests__combine_import_from.py.snap | 2 +- ...ter__rules__isort__tests__comments.py.snap | 18 +++++++++--------- ..._isort__tests__deduplicate_imports.py.snap | 2 +- ...es__isort__tests__detect_same_package.snap | 2 +- ...les__isort__tests__fit_line_length.py.snap | 2 +- ...rt__tests__fit_line_length_comment.py.snap | 2 +- ...orce_single_line_force_single_line.py.snap | 10 +++++----- ..._tests__force_sort_within_sections.py.snap | 4 ++-- ...ections_force_sort_within_sections.py.snap | 4 ++-- ..._force_sort_within_sections_future.py.snap | 2 +- ...sort_within_sections_with_as_names.py.snap | 2 +- ..._rules__isort__tests__force_to_top.py.snap | 6 +++--- ...__tests__force_to_top_force_to_top.py.snap | 6 +++--- ...__isort__tests__force_wrap_aliases.py.snap | 2 +- ...ce_wrap_aliases_force_wrap_aliases.py.snap | 2 +- ...les__isort__tests__forced_separate.py.snap | 2 +- ...__rules__isort__tests__future_from.py.snap | 2 +- ...kage_first_and_third_party_imports.py.snap | 2 +- ..._rules__isort__tests__if_elif_else.py.snap | 2 +- ...t__tests__import_from_after_import.py.snap | 2 +- ...les__isort__tests__inline_comments.py.snap | 8 ++++---- ...sest_separate_local_folder_imports.py.snap | 2 +- ...lder_separate_local_folder_imports.py.snap | 2 +- ...gth_sort__length_sort_from_imports.py.snap | 2 +- ...ort__length_sort_non_ascii_members.py.snap | 2 +- ...ort__length_sort_non_ascii_modules.py.snap | 2 +- ...gth_sort_straight_and_from_imports.py.snap | 2 +- ...sort__length_sort_straight_imports.py.snap | 2 +- ..._length_sort_with_relative_imports.py.snap | 2 +- ...straight__length_sort_from_imports.py.snap | 2 +- ...gth_sort_straight_and_from_imports.py.snap | 2 +- ...ight__length_sort_straight_imports.py.snap | 2 +- ..._lines_after_imports_nothing_after.py.snap | 10 +++++----- ...s_between_typeslines_between_types.py.snap | 16 ++++++++-------- ...isort__tests__magic_trailing_comma.py.snap | 12 ++++++------ ...rules__isort__tests__natural_order.py.snap | 2 +- ..._isort__tests__no_detect_same_package.snap | 2 +- ...les__isort__tests__no_lines_before.py.snap | 10 +++++----- ...no_lines_before.py_no_lines_before.py.snap | 10 +++++----- ...o_lines_before_with_empty_sections.py.snap | 2 +- ...andard_library_no_standard_library.py.snap | 6 +++--- ...rules__isort__tests__order_by_type.py.snap | 2 +- ..._order_by_type_false_order_by_type.py.snap | 2 +- ..._order_by_type_with_custom_classes.py.snap | 2 +- ..._order_by_type_with_custom_classes.py.snap | 2 +- ...rder_by_type_with_custom_constants.py.snap | 2 +- ...rder_by_type_with_custom_constants.py.snap | 2 +- ...rder_by_type_with_custom_variables.py.snap | 2 +- ...rder_by_type_with_custom_variables.py.snap | 2 +- ...s__order_relative_imports_by_level.py.snap | 2 +- ...ort__tests__preserve_comment_order.py.snap | 2 +- ...isort__tests__preserve_import_star.py.snap | 2 +- ...comments_propagate_inline_comments.py.snap | 2 +- ...ort__tests__reorder_within_section.py.snap | 2 +- ...ort__tests__section_order_sections.py.snap | 2 +- ...s__isort__tests__sections_sections.py.snap | 2 +- ...ests__separate_first_party_imports.py.snap | 2 +- ...rt__tests__separate_future_imports.py.snap | 2 +- ...sts__separate_local_folder_imports.py.snap | 2 +- ...ests__separate_third_party_imports.py.snap | 2 +- ...isort__tests__sort_similar_imports.py.snap | 6 +++--- ...railing_comma_magic_trailing_comma.py.snap | 12 ++++++------ ...__isort__tests__star_before_others.py.snap | 2 +- ...s__pycodestyle__tests__E501_E501_4.py.snap | Bin 8936 -> 8942 bytes ...style__tests__preview__W391_W391_2.py.snap | 10 +++++----- ...valid_syntax@del_incomplete_target.py.snap | 2 +- ...nction_def_unclosed_parameter_list.py.snap | 2 +- ...x@match_stmt_expect_indented_block.py.snap | 2 +- ...@match_stmt_no_newline_before_case.py.snap | 2 +- ...nvalid_syntax@node_range_with_gaps.py.snap | 2 +- ...ents__if_extra_closing_parentheses.py.snap | 2 +- ...ax@statements__match__as_pattern_2.py.snap | 2 +- ...ax@statements__match__as_pattern_3.py.snap | 2 +- ...alid_syntax@try_stmt_invalid_order.py.snap | 2 +- ...ax@try_stmt_missing_except_finally.py.snap | 2 +- 85 files changed, 153 insertions(+), 151 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC_syntax_error.py.snap b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC_syntax_error.py.snap index 97d7c647868c1..a14e63a629ca2 100644 --- a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC_syntax_error.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs -snapshot_kind: text --- ISC_syntax_error.py:2:5: SyntaxError: missing closing quote in string literal | @@ -59,7 +58,7 @@ ISC_syntax_error.py:4:1: ISC001 Implicitly concatenated string literals on one l 4 | / "a" """b 5 | | c""" "d | |____^ ISC001 -6 | +6 | 7 | # For f-strings, the `FStringRanges` won't contain the range for | = help: Combine string literals @@ -70,7 +69,7 @@ ISC_syntax_error.py:5:6: SyntaxError: missing closing quote in string literal 4 | "a" """b 5 | c""" "d | ^ -6 | +6 | 7 | # For f-strings, the `FStringRanges` won't contain the range for | @@ -80,7 +79,7 @@ ISC_syntax_error.py:5:8: SyntaxError: Expected a statement 4 | "a" """b 5 | c""" "d | ^ -6 | +6 | 7 | # For f-strings, the `FStringRanges` won't contain the range for 8 | # unterminated f-strings. | @@ -144,7 +143,7 @@ ISC_syntax_error.py:11:1: ISC001 Implicitly concatenated string literals on one 11 | / f"a" f"""b 12 | | c""" f"d {e | |____^ ISC001 -13 | +13 | 14 | ( | = help: Combine string literals @@ -173,10 +172,12 @@ ISC_syntax_error.py:30:1: SyntaxError: unexpected EOF while parsing | 28 | "i" "j" 29 | ) + | ^ | ISC_syntax_error.py:30:1: SyntaxError: f-string: unterminated string | 28 | "i" "j" 29 | ) + | ^ | diff --git a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC002_ISC_syntax_error.py.snap b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC002_ISC_syntax_error.py.snap index 859f4a38891bb..46d99bae675e8 100644 --- a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC002_ISC_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC002_ISC_syntax_error.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs -snapshot_kind: text --- ISC_syntax_error.py:2:5: SyntaxError: missing closing quote in string literal | @@ -47,7 +46,7 @@ ISC_syntax_error.py:5:6: SyntaxError: missing closing quote in string literal 4 | "a" """b 5 | c""" "d | ^ -6 | +6 | 7 | # For f-strings, the `FStringRanges` won't contain the range for | @@ -57,7 +56,7 @@ ISC_syntax_error.py:5:8: SyntaxError: Expected a statement 4 | "a" """b 5 | c""" "d | ^ -6 | +6 | 7 | # For f-strings, the `FStringRanges` won't contain the range for 8 | # unterminated f-strings. | @@ -127,10 +126,12 @@ ISC_syntax_error.py:30:1: SyntaxError: unexpected EOF while parsing | 28 | "i" "j" 29 | ) + | ^ | ISC_syntax_error.py:30:1: SyntaxError: f-string: unterminated string | 28 | "i" "j" 29 | ) + | ^ | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__1_separate_subpackage_first_and_third_party_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__1_separate_subpackage_first_and_third_party_imports.py.snap index a0a0a2d9486ce..96dd91f39be72 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__1_separate_subpackage_first_and_third_party_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__1_separate_subpackage_first_and_third_party_imports.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -12,6 +11,7 @@ separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block 6 | | import foo 7 | | import foo.bar 8 | | import foo.bar.baz + | |___________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__2_separate_subpackage_first_and_third_party_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__2_separate_subpackage_first_and_third_party_imports.py.snap index b8a7ec94ee9c2..2261dbec6d713 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__2_separate_subpackage_first_and_third_party_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__2_separate_subpackage_first_and_third_party_imports.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -12,6 +11,7 @@ separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block 6 | | import foo 7 | | import foo.bar 8 | | import foo.bar.baz + | |___________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__add_newline_before_comments.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__add_newline_before_comments.py.snap index e57f95fe89a1e..7facab52b30dc 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__add_newline_before_comments.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__add_newline_before_comments.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- add_newline_before_comments.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -11,6 +10,7 @@ add_newline_before_comments.py:1:1: I001 [*] Import block is un-sorted or un-for 5 | | # This is a comment, but it starts a new section, so we don't need to add a newline 6 | | # before it. 7 | | import leading_prefix + | |______________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__as_imports_comments.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__as_imports_comments.py.snap index 6913e7d70a31e..8cf3015dac577 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__as_imports_comments.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__as_imports_comments.py.snap @@ -1,24 +1,24 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- as_imports_comments.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from foo import ( # Comment on `foo` 2 | | Member as Alias, # Comment on `Alias` 3 | | ) - 4 | | + 4 | | 5 | | from bar import ( # Comment on `bar` 6 | | Member, # Comment on `Member` 7 | | ) - 8 | | + 8 | | 9 | | from baz import ( # Comment on `baz` 10 | | Member as Alias # Comment on `Alias` 11 | | ) -12 | | +12 | | 13 | | from bop import ( # Comment on `bop` 14 | | Member # Comment on `Member` 15 | | ) + | |__^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__case_sensitive_case_sensitive.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__case_sensitive_case_sensitive.py.snap index 7120fa9788d31..4823f977bbe71 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__case_sensitive_case_sensitive.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__case_sensitive_case_sensitive.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- case_sensitive.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -13,6 +12,7 @@ case_sensitive.py:1:1: I001 [*] Import block is un-sorted or un-formatted 7 | | import f 8 | | from g import a, B, c 9 | | from h import A, b, C + | |______________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__closest_to_furthest_relative_imports_order.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__closest_to_furthest_relative_imports_order.py.snap index b01de83984420..47fa779dc2d95 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__closest_to_furthest_relative_imports_order.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__closest_to_furthest_relative_imports_order.py.snap @@ -1,12 +1,12 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- relative_imports_order.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from ... import a 2 | | from .. import b 3 | | from . import c + | |________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports.py.snap index e592fbea13d42..5d94963222bd5 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- combine_as_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -8,6 +7,7 @@ combine_as_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted 2 | | from module import CONSTANT 3 | | from module import function 4 | | from module import function as f + | |_________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports_combine_as_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports_combine_as_imports.py.snap index 5997aa9ceee7d..6a5076f49e2cd 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports_combine_as_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports_combine_as_imports.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- combine_as_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -8,6 +7,7 @@ combine_as_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted 2 | | from module import CONSTANT 3 | | from module import function 4 | | from module import function as f + | |_________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_import_from.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_import_from.py.snap index 4cab097732de3..db9adb08c3b1a 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_import_from.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_import_from.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- combine_import_from.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -9,6 +8,7 @@ combine_import_from.py:1:1: I001 [*] Import block is un-sorted or un-formatted 3 | | from collections import Collection 4 | | from collections import ChainMap 5 | | from collections import MutableSequence, MutableMapping + | |________________________________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__comments.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__comments.py.snap index 61e9508f0723a..d00129855da3c 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__comments.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__comments.py.snap @@ -1,23 +1,22 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- comments.py:3:1: I001 [*] Import block is un-sorted or un-formatted | 1 | # Comment 1 2 | # Comment 2 3 | / import D - 4 | | + 4 | | 5 | | # Comment 3a 6 | | import C - 7 | | + 7 | | 8 | | # Comment 3b 9 | | import C -10 | | +10 | | 11 | | import B # Comment 4 -12 | | +12 | | 13 | | # Comment 5 -14 | | +14 | | 15 | | # Comment 6 16 | | from A import ( 17 | | a, # Comment 7 @@ -29,14 +28,15 @@ comments.py:3:1: I001 [*] Import block is un-sorted or un-formatted 23 | | b, # Comment 10 24 | | c, # Comment 11 25 | | ) -26 | | +26 | | 27 | | from D import a_long_name_to_force_multiple_lines # Comment 12 28 | | from D import another_long_name_to_force_multiple_lines # Comment 13 -29 | | +29 | | 30 | | from E import a # Comment 1 -31 | | +31 | | 32 | | from F import a # Comment 1 33 | | from F import b + | |________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__deduplicate_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__deduplicate_imports.py.snap index 2c9617e08c7e1..bb92e7460bfec 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__deduplicate_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__deduplicate_imports.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- deduplicate_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -8,6 +7,7 @@ deduplicate_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted 2 | | import os 3 | | import os as os1 4 | | import os as os2 + | |_________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__detect_same_package.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__detect_same_package.snap index 028912b06f51a..09deae822ff90 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__detect_same_package.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__detect_same_package.snap @@ -1,12 +1,12 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- bar.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / import os 2 | | import pandas 3 | | import foo.baz + | |_______________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length.py.snap index 1d16dfe29051f..29f158aad33ef 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- fit_line_length.py:7:1: I001 [*] Import block is un-sorted or un-formatted | @@ -13,6 +12,7 @@ fit_line_length.py:7:1: I001 [*] Import block is un-sorted or un-formatted 12 | | from line_with_93 import ( 13 | | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 14 | | ) + | |______^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length_comment.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length_comment.py.snap index ca23140626295..85627547e979a 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length_comment.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length_comment.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- fit_line_length_comment.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -12,6 +11,7 @@ fit_line_length_comment.py:1:1: I001 [*] Import block is un-sorted or un-formatt 6 | | from f import g # 012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ 7 | | # The next import doesn't fit on one line. 8 | | from h import i # 012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9 + | |__________________________________________________________________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_single_line_force_single_line.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_single_line_force_single_line.py.snap index cfd74fe0f2419..af21d3de8b2ed 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_single_line_force_single_line.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_single_line_force_single_line.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- force_single_line.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -12,25 +11,26 @@ force_single_line.py:1:1: I001 [*] Import block is un-sorted or un-formatted 6 | | from json import load 7 | | from json import loads as json_loads 8 | | from logging.handlers import StreamHandler, FileHandler - 9 | | + 9 | | 10 | | # comment 1 11 | | from third_party import lib1, lib2, \ 12 | | lib3, lib7, lib5, lib6 13 | | # comment 2 14 | | from third_party import lib4 -15 | | +15 | | 16 | | from foo import bar # comment 3 17 | | from foo2 import bar2 # comment 4 18 | | from foo3 import bar3, baz3 # comment 5 -19 | | +19 | | 20 | | # comment 6 21 | | from bar import ( 22 | | a, # comment 7 23 | | b, # comment 8 24 | | ) -25 | | +25 | | 26 | | # comment 9 27 | | from baz import * # comment 10 + | |________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections.py.snap index 1592f6397172f..2f63beb4577dd 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- force_sort_within_sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -11,12 +10,13 @@ force_sort_within_sections.py:1:1: I001 [*] Import block is un-sorted or un-form 5 | | from z import z1 6 | | import b as b1 # import_as 7 | | import z - 8 | | + 8 | | 9 | | from ..parent import * 10 | | from .my import fn 11 | | from . import my 12 | | from .my.nested import fn2 13 | | from ...grandparent import fn3 + | |_______________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections.py.snap index abe86b24d5fed..bc09ab5dc0ac8 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- force_sort_within_sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -11,12 +10,13 @@ force_sort_within_sections.py:1:1: I001 [*] Import block is un-sorted or un-form 5 | | from z import z1 6 | | import b as b1 # import_as 7 | | import z - 8 | | + 8 | | 9 | | from ..parent import * 10 | | from .my import fn 11 | | from . import my 12 | | from .my.nested import fn2 13 | | from ...grandparent import fn3 + | |_______________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_future.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_future.py.snap index 19613adbb00c0..e7d9653e67493 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_future.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_future.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- force_sort_within_sections_future.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / import __future__ 2 | | from __future__ import annotations + | |___________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_with_as_names.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_with_as_names.py.snap index 2919ca2ee5a83..98278842d3c1c 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_with_as_names.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_with_as_names.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- force_sort_within_sections_with_as_names.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -9,6 +8,7 @@ force_sort_within_sections_with_as_names.py:1:1: I001 [*] Import block is un-sor 3 | | from datetime import timedelta 4 | | import datetime as dt 5 | | import datetime + | |________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top.py.snap index c6157cbf701ff..6786ce2d70179 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- force_to_top.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -10,7 +9,7 @@ force_to_top.py:1:1: I001 [*] Import block is un-sorted or un-formatted 4 | | import lib1 5 | | import lib3 6 | | import lib4 - 7 | | + 7 | | 8 | | import foo 9 | | import z 10 | | from foo import bar @@ -22,11 +21,12 @@ force_to_top.py:1:1: I001 [*] Import block is un-sorted or un-formatted 16 | | from lib5 import lib2 17 | | from lib4 import lib2 18 | | from lib5 import lib1 -19 | | +19 | | 20 | | import lib3.lib4 21 | | import lib3.lib4.lib5 22 | | from lib3.lib4 import foo 23 | | from lib3.lib4.lib5 import foo + | |_______________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top_force_to_top.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top_force_to_top.py.snap index b77287353043e..ab4c3740c54ac 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top_force_to_top.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top_force_to_top.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- force_to_top.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -10,7 +9,7 @@ force_to_top.py:1:1: I001 [*] Import block is un-sorted or un-formatted 4 | | import lib1 5 | | import lib3 6 | | import lib4 - 7 | | + 7 | | 8 | | import foo 9 | | import z 10 | | from foo import bar @@ -22,11 +21,12 @@ force_to_top.py:1:1: I001 [*] Import block is un-sorted or un-formatted 16 | | from lib5 import lib2 17 | | from lib4 import lib2 18 | | from lib5 import lib1 -19 | | +19 | | 20 | | import lib3.lib4 21 | | import lib3.lib4.lib5 22 | | from lib3.lib4 import foo 23 | | from lib3.lib4.lib5 import foo + | |_______________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases.py.snap index df767bb976ef7..3a91cfccbf24a 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases.py.snap @@ -1,12 +1,12 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- force_wrap_aliases.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from .a import a1 as a1, a2 as a2 2 | | from .b import b1 as b1 3 | | from .c import c1 + | |__________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases_force_wrap_aliases.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases_force_wrap_aliases.py.snap index ce99622c1d25b..dcd5c53e188be 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases_force_wrap_aliases.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases_force_wrap_aliases.py.snap @@ -1,12 +1,12 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- force_wrap_aliases.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from .a import a1 as a1, a2 as a2 2 | | from .b import b1 as b1 3 | | from .c import c1 + | |__________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__forced_separate.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__forced_separate.py.snap index 273723b3fa02d..7f568238e3c10 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__forced_separate.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__forced_separate.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- forced_separate.py:3:1: I001 [*] Import block is un-sorted or un-formatted | @@ -12,6 +11,7 @@ forced_separate.py:3:1: I001 [*] Import block is un-sorted or un-formatted 6 | | from experiments.starry import * 7 | | from experiments.weird import varieties 8 | | from office_helper.assistants import entity_registry as er + | |___________________________________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__future_from.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__future_from.py.snap index 03677390cfa0d..1ce4c428d915c 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__future_from.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__future_from.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- future_from.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / import __future__ 2 | | from __future__ import annotations + | |___________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__glob_1_separate_subpackage_first_and_third_party_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__glob_1_separate_subpackage_first_and_third_party_imports.py.snap index a0a0a2d9486ce..96dd91f39be72 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__glob_1_separate_subpackage_first_and_third_party_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__glob_1_separate_subpackage_first_and_third_party_imports.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -12,6 +11,7 @@ separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block 6 | | import foo 7 | | import foo.bar 8 | | import foo.bar.baz + | |___________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__if_elif_else.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__if_elif_else.py.snap index cc45519b32d69..c6b216631faef 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__if_elif_else.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__if_elif_else.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- if_elif_else.py:6:1: I001 [*] Import block is un-sorted or un-formatted | @@ -8,6 +7,7 @@ if_elif_else.py:6:1: I001 [*] Import block is un-sorted or un-formatted 5 | else: 6 | / from setuptools.command.sdist import sdist as _sdist 7 | | from distutils.command.sdist import sdist as _sdist + | |________________________________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__import_from_after_import.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__import_from_after_import.py.snap index 5f6acddeebcf8..18830525cdefc 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__import_from_after_import.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__import_from_after_import.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- import_from_after_import.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from collections import Collection 2 | | import os + | |__________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__inline_comments.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__inline_comments.py.snap index d8bbe22239d9d..aa5a257835069 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__inline_comments.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__inline_comments.py.snap @@ -1,20 +1,20 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- inline_comments.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from a.prometheus.metrics import ( # type:ignore[attr-defined] 2 | | TERMINAL_CURRENTLY_RUNNING_TOTAL, 3 | | ) - 4 | | + 4 | | 5 | | from b.prometheus.metrics import ( 6 | | TERMINAL_CURRENTLY_RUNNING_TOTAL, # type:ignore[attr-defined] 7 | | ) - 8 | | + 8 | | 9 | | from c.prometheus.metrics import TERMINAL_CURRENTLY_RUNNING_TOTAL # type:ignore[attr-defined] -10 | | +10 | | 11 | | from d.prometheus.metrics import TERMINAL_CURRENTLY_RUNNING_TOTAL, OTHER_RUNNING_TOTAL # type:ignore[attr-defined] + | |____________________________________________________________________________________________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_closest_separate_local_folder_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_closest_separate_local_folder_imports.py.snap index 542f24610be3b..885d2278a2bbd 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_closest_separate_local_folder_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_closest_separate_local_folder_imports.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- separate_local_folder_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -11,6 +10,7 @@ separate_local_folder_imports.py:1:1: I001 [*] Import block is un-sorted or un-f 5 | | from . import leading_prefix 6 | | from .. import trailing_prefix 7 | | from ruff import check + | |_______________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_separate_local_folder_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_separate_local_folder_imports.py.snap index 89d704758afe9..e0a97a7a27bb0 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_separate_local_folder_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_separate_local_folder_imports.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- separate_local_folder_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -11,6 +10,7 @@ separate_local_folder_imports.py:1:1: I001 [*] Import block is un-sorted or un-f 5 | | from . import leading_prefix 6 | | from .. import trailing_prefix 7 | | from ruff import check + | |_______________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_from_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_from_imports.py.snap index 4eae12de52c51..8a435d4b4734d 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_from_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_from_imports.py.snap @@ -1,12 +1,12 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- length_sort_from_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from mediuuuuuuuuuuum import a 2 | | from short import b 3 | | from loooooooooooooooooooooog import c + | |_______________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_members.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_members.py.snap index 75cd508129276..15485adb20b4d 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_members.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_members.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- length_sort_non_ascii_members.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -15,6 +14,7 @@ length_sort_non_ascii_members.py:1:1: I001 [*] Import block is un-sorted or un-f 9 | | mediuuuuuum, 10 | | λοοοοοοοοοοοοοονγ, 11 | | ) + | |__^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_modules.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_modules.py.snap index c2b5ab2b6c781..08357658300d4 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_modules.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_modules.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- length_sort_non_ascii_modules.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -13,6 +12,7 @@ length_sort_non_ascii_modules.py:1:1: I001 [*] Import block is un-sorted or un-f 7 | | import λοοοοοοοοοοοοοονγ 8 | | import μεδιυυυυυμ 9 | | import looooooooooooooong + | |__________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_and_from_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_and_from_imports.py.snap index e514815c0120e..1acdb72464cb7 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_and_from_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_and_from_imports.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- length_sort_straight_and_from_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -10,6 +9,7 @@ length_sort_straight_and_from_imports.py:1:1: I001 [*] Import block is un-sorted 4 | | from looooooooooooooong import a 5 | | from mediuuuum import c 6 | | from short import b + | |____________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_imports.py.snap index 7338fbae63328..78f0c7db02287 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_imports.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- length_sort_straight_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -8,6 +7,7 @@ length_sort_straight_imports.py:1:1: I001 [*] Import block is un-sorted or un-fo 2 | | import short 3 | | import looooooooooooooooong 4 | | import mediuuuuuuma + | |____________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_with_relative_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_with_relative_imports.py.snap index 67e98d0dab3a6..1c169709b5cb1 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_with_relative_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_with_relative_imports.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- length_sort_with_relative_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -11,6 +10,7 @@ length_sort_with_relative_imports.py:1:1: I001 [*] Import block is un-sorted or 5 | | from . import d 6 | | from .mediuuuum import a 7 | | from ......short import b + | |__________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_from_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_from_imports.py.snap index dc6f95ebfa2a0..8fd13f7dcc447 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_from_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_from_imports.py.snap @@ -1,12 +1,12 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- length_sort_from_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from mediuuuuuuuuuuum import a 2 | | from short import b 3 | | from loooooooooooooooooooooog import c + | |_______________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_and_from_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_and_from_imports.py.snap index 85edb87825274..aace2c7a87b4e 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_and_from_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_and_from_imports.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- length_sort_straight_and_from_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -10,6 +9,7 @@ length_sort_straight_and_from_imports.py:1:1: I001 [*] Import block is un-sorted 4 | | from looooooooooooooong import a 5 | | from mediuuuum import c 6 | | from short import b + | |____________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_imports.py.snap index 7338fbae63328..78f0c7db02287 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_imports.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- length_sort_straight_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -8,6 +7,7 @@ length_sort_straight_imports.py:1:1: I001 [*] Import block is un-sorted or un-fo 2 | | import short 3 | | import looooooooooooooooong 4 | | import mediuuuuuuma + | |____________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_nothing_after.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_nothing_after.py.snap index 031bcb5070796..738ecdc0a19b2 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_nothing_after.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_nothing_after.py.snap @@ -1,18 +1,18 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- lines_after_imports_nothing_after.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from __future__ import annotations -2 | | +2 | | 3 | | from typing import Any -4 | | +4 | | 5 | | from requests import Session -6 | | +6 | | 7 | | from my_first_party import my_first_party_object -8 | | +8 | | 9 | | from . import my_local_folder_object + | |_____________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_between_typeslines_between_types.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_between_typeslines_between_types.py.snap index 1b48f1050f66c..999eef901023b 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_between_typeslines_between_types.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_between_typeslines_between_types.py.snap @@ -1,25 +1,25 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- lines_between_types.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from __future__ import annotations - 2 | | + 2 | | 3 | | import datetime 4 | | import json - 5 | | - 6 | | + 5 | | + 6 | | 7 | | from binascii import hexlify - 8 | | + 8 | | 9 | | import requests -10 | | -11 | | +10 | | +11 | | 12 | | from sanic import Sanic 13 | | from loguru import Logger -14 | | +14 | | 15 | | from . import config 16 | | from .data import Data + | |_______________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__magic_trailing_comma.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__magic_trailing_comma.py.snap index f9942519d4cbd..d0c0490fd662e 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__magic_trailing_comma.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__magic_trailing_comma.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- magic_trailing_comma.py:2:1: I001 [*] Import block is un-sorted or un-formatted | @@ -11,7 +10,7 @@ magic_trailing_comma.py:2:1: I001 [*] Import block is un-sorted or un-formatted 5 | | stdout, 6 | | exit, 7 | | ) - 8 | | + 8 | | 9 | | # No magic comma, this will be rolled into one line. 10 | | from os import ( 11 | | path, @@ -19,29 +18,30 @@ magic_trailing_comma.py:2:1: I001 [*] Import block is un-sorted or un-formatted 13 | | execl, 14 | | execv 15 | | ) -16 | | +16 | | 17 | | from glob import ( 18 | | glob, 19 | | iglob, 20 | | escape, # Ends with a comment, should still treat as magic trailing comma. 21 | | ) -22 | | +22 | | 23 | | # These will be combined, but without a trailing comma. 24 | | from foo import bar 25 | | from foo import baz -26 | | +26 | | 27 | | # These will be combined, _with_ a trailing comma. 28 | | from module1 import member1 29 | | from module1 import ( 30 | | member2, 31 | | member3, 32 | | ) -33 | | +33 | | 34 | | # These will be combined, _with_ a trailing comma. 35 | | from module2 import member1, member2 36 | | from module2 import ( 37 | | member3, 38 | | ) + | |__^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__natural_order.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__natural_order.py.snap index a999e1d40361e..365069c2d2b04 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__natural_order.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__natural_order.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- natural_order.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -20,6 +19,7 @@ natural_order.py:1:1: I001 [*] Import block is un-sorted or un-formatted 14 | | uint32, 15 | | uint64, 16 | | ) + | |__^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_detect_same_package.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_detect_same_package.snap index f83e72de04e9d..0202de948a040 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_detect_same_package.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_detect_same_package.snap @@ -1,12 +1,12 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- bar.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / import os 2 | | import pandas 3 | | import foo.baz + | |_______________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py.snap index 73f379d76f18f..c53337dca3dee 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py.snap @@ -1,18 +1,18 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- no_lines_before.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from __future__ import annotations -2 | | +2 | | 3 | | from typing import Any -4 | | +4 | | 5 | | from requests import Session -6 | | +6 | | 7 | | from my_first_party import my_first_party_object -8 | | +8 | | 9 | | from . import my_local_folder_object + | |_____________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py_no_lines_before.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py_no_lines_before.py.snap index 019ad9b8db0ce..4d4ad9b6f6623 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py_no_lines_before.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py_no_lines_before.py.snap @@ -1,18 +1,18 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- no_lines_before.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from __future__ import annotations -2 | | +2 | | 3 | | from typing import Any -4 | | +4 | | 5 | | from requests import Session -6 | | +6 | | 7 | | from my_first_party import my_first_party_object -8 | | +8 | | 9 | | from . import my_local_folder_object + | |_____________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before_with_empty_sections.py_no_lines_before_with_empty_sections.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before_with_empty_sections.py_no_lines_before_with_empty_sections.py.snap index e2b900a69dabb..0ea69c6c895ad 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before_with_empty_sections.py_no_lines_before_with_empty_sections.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before_with_empty_sections.py_no_lines_before_with_empty_sections.py.snap @@ -1,12 +1,12 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- no_lines_before_with_empty_sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from __future__ import annotations 2 | | from typing import Any 3 | | from . import my_local_folder_object + | |_____________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_standard_library_no_standard_library.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_standard_library_no_standard_library.py.snap index fe135c4a7c56b..5ca5c30e5a599 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_standard_library_no_standard_library.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_standard_library_no_standard_library.py.snap @@ -1,18 +1,18 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- no_standard_library.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from __future__ import annotations -2 | | +2 | | 3 | | import os 4 | | import django.settings 5 | | from library import foo 6 | | import pytz -7 | | +7 | | 8 | | from . import local 9 | | import sys + | |___________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type.py.snap index f6d316e71f13f..2d9a1bf2d6a9e 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- order_by_type.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -16,6 +15,7 @@ order_by_type.py:1:1: I001 [*] Import block is un-sorted or un-formatted 10 | | import FOO 11 | | import BAR 12 | | import bar + | |___________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_false_order_by_type.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_false_order_by_type.py.snap index a9a30bb189dc1..01680ba83123d 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_false_order_by_type.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_false_order_by_type.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- order_by_type.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -16,6 +15,7 @@ order_by_type.py:1:1: I001 [*] Import block is un-sorted or un-formatted 10 | | import FOO 11 | | import BAR 12 | | import bar + | |___________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes.py.snap index 787026cde41b8..165c2e0a4a131 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- order_by_type_with_custom_classes.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -8,6 +7,7 @@ order_by_type_with_custom_classes.py:1:1: I001 [*] Import block is un-sorted or 2 | | from subprocess import N_CLASS, PIPE, Popen, STDOUT 3 | | from module import CLASS, Class, CONSTANT, function, BASIC, Apple 4 | | from torch.nn import SELU, AClass, A_CONSTANT + | |______________________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes_order_by_type_with_custom_classes.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes_order_by_type_with_custom_classes.py.snap index 63397c3886f7f..da6c3f5a50cdc 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes_order_by_type_with_custom_classes.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes_order_by_type_with_custom_classes.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- order_by_type_with_custom_classes.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -8,6 +7,7 @@ order_by_type_with_custom_classes.py:1:1: I001 [*] Import block is un-sorted or 2 | | from subprocess import N_CLASS, PIPE, Popen, STDOUT 3 | | from module import CLASS, Class, CONSTANT, function, BASIC, Apple 4 | | from torch.nn import SELU, AClass, A_CONSTANT + | |______________________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants.py.snap index c0a083b0a53ad..89f11191c3270 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- order_by_type_with_custom_constants.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from sklearn.svm import XYZ, func, variable, Const, Klass, constant 2 | | from subprocess import First, var, func, Class, konst, A_constant, Last, STDOUT + | |________________________________________________________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants_order_by_type_with_custom_constants.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants_order_by_type_with_custom_constants.py.snap index d1e18cb875641..608e9c4225a33 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants_order_by_type_with_custom_constants.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants_order_by_type_with_custom_constants.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- order_by_type_with_custom_constants.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from sklearn.svm import XYZ, func, variable, Const, Klass, constant 2 | | from subprocess import First, var, func, Class, konst, A_constant, Last, STDOUT + | |________________________________________________________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables.py.snap index 26485f5bb5edd..1662d9210fda1 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- order_by_type_with_custom_variables.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from sklearn.svm import VAR, Class, MyVar, CONST, abc 2 | | from subprocess import utils, var_ABC, Variable, Klass, CONSTANT, exe + | |______________________________________________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables_order_by_type_with_custom_variables.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables_order_by_type_with_custom_variables.py.snap index 0188217dd3d34..ea153619f67c9 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables_order_by_type_with_custom_variables.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables_order_by_type_with_custom_variables.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- order_by_type_with_custom_variables.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from sklearn.svm import VAR, Class, MyVar, CONST, abc 2 | | from subprocess import utils, var_ABC, Variable, Klass, CONSTANT, exe + | |______________________________________________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_relative_imports_by_level.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_relative_imports_by_level.py.snap index 163a40ce4c85c..15d86c10dc9ec 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_relative_imports_by_level.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_relative_imports_by_level.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- order_relative_imports_by_level.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -8,6 +7,7 @@ order_relative_imports_by_level.py:1:1: I001 [*] Import block is un-sorted or un 2 | | from ..a import a 3 | | from ..b import a 4 | | from .b import a + | |_________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_comment_order.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_comment_order.py.snap index d6b5c74842661..dea350e6ea391 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_comment_order.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_comment_order.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- preserve_comment_order.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -15,6 +14,7 @@ preserve_comment_order.py:1:1: I001 [*] Import block is un-sorted or un-formatte 9 | | # EIEIO 10 | | from errno import EIO 11 | | import abc + | |___________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_import_star.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_import_star.py.snap index 7af1fcf1682a5..bf86607544840 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_import_star.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_import_star.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- preserve_import_star.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -10,6 +9,7 @@ preserve_import_star.py:1:1: I001 [*] Import block is un-sorted or un-formatted 4 | | from some_module import some_class # Aside 5 | | # Above 6 | | from some_module import * # Aside + | |___________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__propagate_inline_comments_propagate_inline_comments.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__propagate_inline_comments_propagate_inline_comments.py.snap index 709cc224ca306..c56a7b308d8fd 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__propagate_inline_comments_propagate_inline_comments.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__propagate_inline_comments_propagate_inline_comments.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- propagate_inline_comments.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -8,6 +7,7 @@ propagate_inline_comments.py:1:1: I001 [*] Import block is un-sorted or un-forma 2 | | a_long_variable_name_that_causes_problems, 3 | | items, 4 | | ) + | |__^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__reorder_within_section.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__reorder_within_section.py.snap index baed688328010..c507aba5c5f3a 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__reorder_within_section.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__reorder_within_section.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- reorder_within_section.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / import sys 2 | | import os + | |__________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__section_order_sections.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__section_order_sections.py.snap index 771c7787205ea..da111cf3efcb8 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__section_order_sections.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__section_order_sections.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -11,6 +10,7 @@ sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted 5 | | import django.settings 6 | | from library import foo 7 | | from . import local + | |____________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_sections.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_sections.py.snap index f64def1fe0571..0e3a3aa836fb3 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_sections.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_sections.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -11,6 +10,7 @@ sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted 5 | | import django.settings 6 | | from library import foo 7 | | from . import local + | |____________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_first_party_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_first_party_imports.py.snap index 4d825d65681c5..16f3d827bb888 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_first_party_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_first_party_imports.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- separate_first_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -9,6 +8,7 @@ separate_first_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-fo 3 | | import numpy as np 4 | | import os 5 | | from leading_prefix import Class + | |_________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_future_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_future_imports.py.snap index 9c916a94c20e2..1a5c98fadadd6 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_future_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_future_imports.py.snap @@ -1,12 +1,12 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- separate_future_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / import sys 2 | | import os 3 | | from __future__ import annotations + | |___________________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_local_folder_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_local_folder_imports.py.snap index a7a86d4796cc5..51da602b4d70d 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_local_folder_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_local_folder_imports.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- separate_local_folder_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -11,6 +10,7 @@ separate_local_folder_imports.py:1:1: I001 [*] Import block is un-sorted or un-f 5 | | from . import leading_prefix 6 | | from .. import trailing_prefix 7 | | from ruff import check + | |_______________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_third_party_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_third_party_imports.py.snap index 5b23952b2ec39..1f7f90430e6d4 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_third_party_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_third_party_imports.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- separate_third_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -8,6 +7,7 @@ separate_third_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-fo 2 | | import sys 3 | | import numpy as np 4 | | import os + | |__________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sort_similar_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sort_similar_imports.py.snap index 2dadc46d8ee2e..ecb5a76834fc3 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sort_similar_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sort_similar_imports.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- sort_similar_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -19,17 +18,18 @@ sort_similar_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted 13 | | from a import b as y 14 | | from b import C 15 | | from b import c as d -16 | | +16 | | 17 | | import A 18 | | import a 19 | | import b 20 | | import B -21 | | +21 | | 22 | | import x as y 23 | | import x as A 24 | | import x as Y 25 | | import x 26 | | import x as a + | |______________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split_on_trailing_comma_magic_trailing_comma.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split_on_trailing_comma_magic_trailing_comma.py.snap index d7dcb367c42e8..1a3b4bccd05f8 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split_on_trailing_comma_magic_trailing_comma.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split_on_trailing_comma_magic_trailing_comma.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- magic_trailing_comma.py:2:1: I001 [*] Import block is un-sorted or un-formatted | @@ -11,7 +10,7 @@ magic_trailing_comma.py:2:1: I001 [*] Import block is un-sorted or un-formatted 5 | | stdout, 6 | | exit, 7 | | ) - 8 | | + 8 | | 9 | | # No magic comma, this will be rolled into one line. 10 | | from os import ( 11 | | path, @@ -19,29 +18,30 @@ magic_trailing_comma.py:2:1: I001 [*] Import block is un-sorted or un-formatted 13 | | execl, 14 | | execv 15 | | ) -16 | | +16 | | 17 | | from glob import ( 18 | | glob, 19 | | iglob, 20 | | escape, # Ends with a comment, should still treat as magic trailing comma. 21 | | ) -22 | | +22 | | 23 | | # These will be combined, but without a trailing comma. 24 | | from foo import bar 25 | | from foo import baz -26 | | +26 | | 27 | | # These will be combined, _with_ a trailing comma. 28 | | from module1 import member1 29 | | from module1 import ( 30 | | member2, 31 | | member3, 32 | | ) -33 | | +33 | | 34 | | # These will be combined, _with_ a trailing comma. 35 | | from module2 import member1, member2 36 | | from module2 import ( 37 | | member3, 38 | | ) + | |__^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__star_before_others.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__star_before_others.py.snap index ef8b32117ba13..97c473a7ef4fe 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__star_before_others.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__star_before_others.py.snap @@ -1,12 +1,12 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- star_before_others.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from .logging import config_logging 2 | | from .settings import ENV 3 | | from .settings import * + | |________________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E501_E501_4.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E501_E501_4.py.snap index 1a5001103eb1ba56f689288f81acfd5b9ba17786..8af342273e06a2536fe80f1b4449c2effa2d15ee 100644 GIT binary patch delta 239 zcmaFi`p$KN&BlOOrpX12BAX8|X)=Ntf0&^R3sxwjgbm8rzz$`+;Q%v)H>-2$fOH9O zPUY5xFqZH@8IO6P3?+UjBT)d#SRm*OQT$a1%J33_GUkgy8DGSp3{MFtW1b|G@mUJW a@Q{Hr=E}N24E!tyWq2w;8S@pv3^o8_KS(tI delta 213 zcmaFo`oeXBjc{>ZVnK06eo1_GW?qVwLP=^x$wuoqrpbY9!kgDJX)=Ntub80>byiKr z&4Fw-5aEUFP~m$VKw%CpJI2lK-1dx{+j)S*ab6(7&JQHq1?(9oKa>*QJWJ3C!uTKr zWw?nz8FNITj89@vhKB@{F;CKoaq~l|P>5D986dA$HjHue6FDGZtpFq@DTXn!aw#a( GZ~*{@Qbm{m diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_2.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_2.py.snap index 93c60c5fa0bcd..2bf80006545ba 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_2.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_2.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- W391_2.py:14:1: W391 [*] Too many newlines at end of file | 12 | foo() 13 | bar() -14 | / -15 | | -16 | | -17 | | +14 | / +15 | | +16 | | +17 | | + | |__^ W391 | = help: Remove trailing newlines diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_incomplete_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_incomplete_target.py.snap index 99399b3d4f3b9..b17df25feb8d7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_incomplete_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_incomplete_target.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/inline/err/del_incomplete_target.py -snapshot_kind: text --- ## AST @@ -122,4 +121,5 @@ Module( | 3 | del x, y[ 4 | z + | ^ Syntax Error: unexpected EOF while parsing | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap index c7d55eaf79194..bc3b151c5e388 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/inline/err/function_def_unclosed_parameter_list.py -snapshot_kind: text --- ## AST @@ -231,4 +230,5 @@ Module( | 4 | def foo(a: int, b: str 5 | x = 10 + | ^ Syntax Error: unexpected EOF while parsing | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expect_indented_block.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expect_indented_block.py.snap index 211828f6faf97..5ba948d16b052 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expect_indented_block.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expect_indented_block.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/inline/err/match_stmt_expect_indented_block.py -snapshot_kind: text --- ## AST @@ -63,4 +62,5 @@ Module( | 1 | match foo: 2 | case _: ... + | ^ Syntax Error: Expected dedent, found end of file | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_no_newline_before_case.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_no_newline_before_case.py.snap index 777094c7dcf2b..6a9ba216b3a0c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_no_newline_before_case.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_no_newline_before_case.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/inline/err/match_stmt_no_newline_before_case.py -snapshot_kind: text --- ## AST @@ -61,4 +60,5 @@ Module( | 1 | match foo: case _: ... + | ^ Syntax Error: Expected dedent, found end of file | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@node_range_with_gaps.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@node_range_with_gaps.py.snap index 3d3d5bba2754a..e6364e6c4c577 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@node_range_with_gaps.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@node_range_with_gaps.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/inline/err/node_range_with_gaps.py -snapshot_kind: text --- ## AST @@ -120,4 +119,5 @@ Module( | 2 | def bar(): ... 3 | def baz + | ^ Syntax Error: Expected ')', found end of file | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_closing_parentheses.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_closing_parentheses.py.snap index a792f464f47bd..ea5649412f7d1 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_closing_parentheses.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_closing_parentheses.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/statements/if_extra_closing_parentheses.py -snapshot_kind: text --- ## AST @@ -77,4 +76,5 @@ Module( | 2 | if True)): 3 | pass + | ^ Syntax Error: Expected a statement | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_2.py.snap index d44881f3fb44a..1607c5185fb0f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_2.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/statements/match/as_pattern_2.py -snapshot_kind: text --- ## AST @@ -124,4 +123,5 @@ Module( | 4 | case x as y + 1j: 5 | pass + | ^ Syntax Error: Expected a statement | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_3.py.snap index ef627ceb553c6..cf7490e5fd2fb 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_3.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/statements/match/as_pattern_3.py -snapshot_kind: text --- ## AST @@ -152,4 +151,5 @@ Module( | 4 | case {(x as y): 1}: 5 | pass + | ^ Syntax Error: Expected a statement | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_invalid_order.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_invalid_order.py.snap index 2eb034703dc36..f3525218f438c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_invalid_order.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_invalid_order.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/inline/err/try_stmt_invalid_order.py -snapshot_kind: text --- ## AST @@ -81,4 +80,5 @@ Module( | 5 | else: 6 | pass + | ^ Syntax Error: Expected a statement | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_missing_except_finally.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_missing_except_finally.py.snap index 500164d52dc36..df9779babddc4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_missing_except_finally.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_missing_except_finally.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/inline/err/try_stmt_missing_except_finally.py -snapshot_kind: text --- ## AST @@ -67,4 +66,5 @@ Module( | 5 | else: 6 | pass + | ^ Syntax Error: Expected `except` or `finally` after `try` block | From 95bb118bc9b86b3411002ab525c192c23b8c1140 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Tue, 7 Jan 2025 13:48:33 -0500 Subject: [PATCH 07/18] test: update formatting of multi-line annotations It's hard to grok the change from the snapshot diffs alone, so here's one example. Before: PYI021.pyi:15:5: PYI021 [*] Docstrings should not be included in stubs | 14 | class Baz: 15 | """Multiline docstring | _____^ 16 | | 17 | | Lorem ipsum dolor sit amet 18 | | """ | |_______^ PYI021 19 | 20 | def __init__(self) -> None: ... | = help: Remove docstring And now after: PYI021.pyi:15:5: PYI021 [*] Docstrings should not be included in stubs | 14 | class Baz: 15 | / """Multiline docstring 16 | | 17 | | Lorem ipsum dolor sit amet 18 | | """ | |_______^ PYI021 19 | 20 | def __init__(self) -> None: ... | = help: Remove docstring I personally think both of these are fine. If we felt strongly, I could investigate reverting to the old style, but the new style seems okay to me. In other words, these updates I believe are just cosmetic and not a bug fix. --- ...e8_async__tests__ASYNC100_ASYNC100.py.snap | 34 +-- ...e8_async__tests__ASYNC110_ASYNC110.py.snap | 16 +- ...s__flake8_bandit__tests__S608_S608.py.snap | 68 +++--- ...__flake8_bugbear__tests__B027_B027.py.snap | 27 +-- ...8_comprehensions__tests__C419_C419.py.snap | 8 +- ...sions__tests__preview__C419_C419_1.py.snap | 6 +- ..._flake8_django__tests__DJ012_DJ012.py.snap | 21 +- ...__rules__flake8_errmsg__tests__custom.snap | 9 +- ...rules__flake8_errmsg__tests__defaults.snap | 12 +- ...icit_str_concat__tests__ISC003_ISC.py.snap | 12 +- ...oncat__tests__multiline_ISC002_ISC.py.snap | 19 +- ...__flake8_pie__tests__PIE800_PIE800.py.snap | 82 ++++---- ...__flake8_pyi__tests__PYI016_PYI016.py.snap | 71 ++++--- ..._flake8_pyi__tests__PYI016_PYI016.pyi.snap | 71 ++++--- ..._flake8_pyi__tests__PYI021_PYI021.pyi.snap | 16 +- ...__flake8_pyi__tests__PYI041_PYI041.py.snap | 13 +- ..._flake8_pyi__tests__PYI041_PYI041.pyi.snap | 25 ++- ...es__flake8_pytest_style__tests__PT003.snap | 4 +- ...flake8_pytest_style__tests__PT006_csv.snap | 4 +- ...e8_pytest_style__tests__PT006_default.snap | 4 +- ...lake8_pytest_style__tests__PT006_list.snap | 4 +- ...est_style__tests__PT007_list_of_lists.snap | 7 +- ...st_style__tests__PT007_list_of_tuples.snap | 7 +- ...st_style__tests__PT007_tuple_of_lists.snap | 13 +- ...t_style__tests__PT007_tuple_of_tuples.snap | 13 +- ...es__flake8_pytest_style__tests__PT012.snap | 38 ++-- ...es__flake8_pytest_style__tests__PT018.snap | 29 ++- ...__flake8_pytest_style__tests__PT027_0.snap | 18 +- ...ing_doubles_over_docstring_doubles.py.snap | 22 +- ...ing_doubles_over_docstring_singles.py.snap | 13 +- ...es_over_docstring_singles_function.py.snap | 4 +- ...ing_singles_over_docstring_doubles.py.snap | 13 +- ...es_over_docstring_doubles_function.py.snap | 4 +- ...ing_singles_over_docstring_singles.py.snap | 24 +-- ...lake8_return__tests__RET503_RET503.py.snap | 44 ++-- ...urn__tests__preview__RET503_RET503.py.snap | 20 +- ...ke8_simplify__tests__SIM102_SIM102.py.snap | 19 +- ...ke8_simplify__tests__SIM103_SIM103.py.snap | 34 +-- ...8_simplify__tests__SIM105_SIM105_0.py.snap | 34 ++- ...8_simplify__tests__SIM105_SIM105_3.py.snap | 4 +- ...ke8_simplify__tests__SIM108_SIM108.py.snap | 20 +- ...ke8_simplify__tests__SIM110_SIM110.py.snap | 51 ++--- ...ke8_simplify__tests__SIM110_SIM111.py.snap | 47 ++--- ...ke8_simplify__tests__SIM114_SIM114.py.snap | 40 ++-- ...ke8_simplify__tests__SIM117_SIM117.py.snap | 7 +- ...ke8_simplify__tests__SIM401_SIM401.py.snap | 20 +- ...g__tests__runtime-cast-value_TC006.py.snap | 19 +- ..._use_pathlib__tests__PTH201_PTH201.py.snap | 13 +- ..._rules__isort__tests__bom_unsorted.py.snap | 5 +- ...les__isort__tests__trailing_suffix.py.snap | 6 +- ...__perflint__tests__PERF203_PERF203.py.snap | 6 +- ...__perflint__tests__PERF401_PERF401.py.snap | 5 +- ...t__tests__preview__PERF401_PERF401.py.snap | 5 +- ...les__pycodestyle__tests__E731_E731.py.snap | 28 ++- ...extraneous-exception_DOC502_google.py.snap | 28 ++- ...-extraneous-exception_DOC502_numpy.py.snap | 28 ++- ...g-extraneous-returns_DOC202_google.py.snap | 20 +- ...ng-extraneous-returns_DOC202_numpy.py.snap | 15 +- ...ng-extraneous-yields_DOC403_google.py.snap | 15 +- ...ing-extraneous-yields_DOC403_numpy.py.snap | 15 +- ...ng-missing-exception_DOC501_google.py.snap | 60 +++--- ...ing-missing-exception_DOC501_numpy.py.snap | 43 ++-- ...ring-missing-returns_DOC201_google.py.snap | 26 +-- ...tring-missing-returns_DOC201_numpy.py.snap | 26 +-- ...tring-missing-yields_DOC402_google.py.snap | 17 +- ...string-missing-yields_DOC402_numpy.py.snap | 26 +-- ...__rules__pydocstyle__tests__D200_D.py.snap | 29 +-- ...ules__pydocstyle__tests__D200_D200.py.snap | 10 +- ...__rules__pydocstyle__tests__D201_D.py.snap | 23 +- ...__rules__pydocstyle__tests__D202_D.py.snap | 23 +- ...__rules__pydocstyle__tests__D203_D.py.snap | 10 +- ...__rules__pydocstyle__tests__D205_D.py.snap | 15 +- ...__rules__pydocstyle__tests__D209_D.py.snap | 11 +- ...__rules__pydocstyle__tests__D210_D.py.snap | 6 +- ...__rules__pydocstyle__tests__D212_D.py.snap | 14 +- ...__rules__pydocstyle__tests__D213_D.py.snap | 172 +++++++-------- ...__rules__pydocstyle__tests__D300_D.py.snap | 9 +- ...ules__pydocstyle__tests__D301_D301.py.snap | 7 +- ...__rules__pydocstyle__tests__D400_D.py.snap | 13 +- ...ules__pydocstyle__tests__D400_D400.py.snap | 24 +-- ...ules__pydocstyle__tests__D401_D401.py.snap | 17 +- ...ules__pydocstyle__tests__D403_D403.py.snap | 70 +++---- ...__rules__pydocstyle__tests__D415_D.py.snap | 13 +- ...__rules__pydocstyle__tests__d209_d400.snap | 7 +- ...tests__PLE1142_await_outside_async.py.snap | 7 +- ..._tests__PLE1310_bad_str_strip_call.py.snap | 36 ++-- ...ts__PLR1702_too_many_nested_blocks.py.snap | 4 +- ...PLR1716_boolean_chained_comparison.py.snap | 19 +- ...nt__tests__PLR1730_if_stmt_min_max.py.snap | 79 ++++--- ...tests__PLR5501_collapsible_else_if.py.snap | 34 +-- ...pylint__tests__PLW0101_unreachable.py.snap | 42 ++-- ...er__rules__pyupgrade__tests__UP012.py.snap | 27 ++- ...er__rules__pyupgrade__tests__UP026.py.snap | 42 ++-- ...__rules__pyupgrade__tests__UP028_0.py.snap | 54 ++--- ...__rules__pyupgrade__tests__UP030_0.py.snap | 93 ++++---- ...__rules__pyupgrade__tests__UP032_0.py.snap | 198 +++++++++--------- ...er__rules__pyupgrade__tests__UP035.py.snap | 94 ++++----- ...es__refurb__tests__FURB110_FURB110.py.snap | 26 +-- ...es__refurb__tests__FURB113_FURB113.py.snap | 31 +-- ...es__refurb__tests__FURB154_FURB154.py.snap | 43 ++-- ...es__refurb__tests__FURB156_FURB156.py.snap | 12 +- ...es__refurb__tests__FURB188_FURB188.py.snap | 38 ++-- ..._rules__ruff__tests__RUF022_RUF022.py.snap | 104 +++++---- ..._rules__ruff__tests__RUF026_RUF026.py.snap | 13 +- ..._rules__ruff__tests__RUF051_RUF051.py.snap | 75 +++---- ...sts__prefer_parentheses_getitem_tuple.snap | 6 +- ...sts__preview__RUF039_RUF039_concat.py.snap | 6 +- ...pe-check-without-type-error_TRY004.py.snap | 4 +- ...__tests__useless-try-except_TRY203.py.snap | 55 ++--- 109 files changed, 1290 insertions(+), 1802 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC100_ASYNC100.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC100_ASYNC100.py.snap index c34bac0442114..2d3adc5b36ce9 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC100_ASYNC100.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC100_ASYNC100.py.snap @@ -1,12 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs -snapshot_kind: text --- ASYNC100.py:8:5: ASYNC100 A `with trio.fail_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | 7 | async def func(): -8 | with trio.fail_after(): - | _____^ +8 | / with trio.fail_after(): 9 | | ... | |___________^ ASYNC100 | @@ -14,8 +12,7 @@ ASYNC100.py:8:5: ASYNC100 A `with trio.fail_after(...):` context does not contai ASYNC100.py:18:5: ASYNC100 A `with trio.move_on_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | 17 | async def func(): -18 | with trio.move_on_after(): - | _____^ +18 | / with trio.move_on_after(): 19 | | ... | |___________^ ASYNC100 | @@ -23,8 +20,7 @@ ASYNC100.py:18:5: ASYNC100 A `with trio.move_on_after(...):` context does not co ASYNC100.py:45:5: ASYNC100 A `with anyio.move_on_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | 44 | async def func(): -45 | with anyio.move_on_after(delay=0.2): - | _____^ +45 | / with anyio.move_on_after(delay=0.2): 46 | | ... | |___________^ ASYNC100 | @@ -32,8 +28,7 @@ ASYNC100.py:45:5: ASYNC100 A `with anyio.move_on_after(...):` context does not c ASYNC100.py:50:5: ASYNC100 A `with anyio.fail_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | 49 | async def func(): -50 | with anyio.fail_after(): - | _____^ +50 | / with anyio.fail_after(): 51 | | ... | |___________^ ASYNC100 | @@ -41,8 +36,7 @@ ASYNC100.py:50:5: ASYNC100 A `with anyio.fail_after(...):` context does not cont ASYNC100.py:55:5: ASYNC100 A `with anyio.CancelScope(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | 54 | async def func(): -55 | with anyio.CancelScope(): - | _____^ +55 | / with anyio.CancelScope(): 56 | | ... | |___________^ ASYNC100 | @@ -50,8 +44,7 @@ ASYNC100.py:55:5: ASYNC100 A `with anyio.CancelScope(...):` context does not con ASYNC100.py:60:5: ASYNC100 A `with anyio.CancelScope(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | 59 | async def func(): -60 | with anyio.CancelScope(), nullcontext(): - | _____^ +60 | / with anyio.CancelScope(), nullcontext(): 61 | | ... | |___________^ ASYNC100 | @@ -59,8 +52,7 @@ ASYNC100.py:60:5: ASYNC100 A `with anyio.CancelScope(...):` context does not con ASYNC100.py:65:5: ASYNC100 A `with anyio.CancelScope(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | 64 | async def func(): -65 | with nullcontext(), anyio.CancelScope(): - | _____^ +65 | / with nullcontext(), anyio.CancelScope(): 66 | | ... | |___________^ ASYNC100 | @@ -68,8 +60,7 @@ ASYNC100.py:65:5: ASYNC100 A `with anyio.CancelScope(...):` context does not con ASYNC100.py:70:5: ASYNC100 A `with asyncio.timeout(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | 69 | async def func(): -70 | async with asyncio.timeout(delay=0.2): - | _____^ +70 | / async with asyncio.timeout(delay=0.2): 71 | | ... | |___________^ ASYNC100 | @@ -77,8 +68,7 @@ ASYNC100.py:70:5: ASYNC100 A `with asyncio.timeout(...):` context does not conta ASYNC100.py:75:5: ASYNC100 A `with asyncio.timeout_at(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | 74 | async def func(): -75 | async with asyncio.timeout_at(when=0.2): - | _____^ +75 | / async with asyncio.timeout_at(when=0.2): 76 | | ... | |___________^ ASYNC100 | @@ -86,8 +76,7 @@ ASYNC100.py:75:5: ASYNC100 A `with asyncio.timeout_at(...):` context does not co ASYNC100.py:85:5: ASYNC100 A `with asyncio.timeout(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | 84 | async def func(): -85 | async with asyncio.timeout(delay=0.2), asyncio.TaskGroup(), asyncio.timeout(delay=0.2): - | _____^ +85 | / async with asyncio.timeout(delay=0.2), asyncio.TaskGroup(), asyncio.timeout(delay=0.2): 86 | | ... | |___________^ ASYNC100 | @@ -95,8 +84,7 @@ ASYNC100.py:85:5: ASYNC100 A `with asyncio.timeout(...):` context does not conta ASYNC100.py:95:5: ASYNC100 A `with asyncio.timeout(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | 94 | async def func(): -95 | async with asyncio.timeout(delay=0.2), asyncio.timeout(delay=0.2): - | _____^ +95 | / async with asyncio.timeout(delay=0.2), asyncio.timeout(delay=0.2): 96 | | ... | |___________^ ASYNC100 | diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC110_ASYNC110.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC110_ASYNC110.py.snap index 1a09109551539..b385e812690fe 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC110_ASYNC110.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC110_ASYNC110.py.snap @@ -1,12 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs -snapshot_kind: text --- ASYNC110.py:7:5: ASYNC110 Use `trio.Event` instead of awaiting `trio.sleep` in a `while` loop | 6 | async def func(): -7 | while True: - | _____^ +7 | / while True: 8 | | await trio.sleep(10) | |____________________________^ ASYNC110 | @@ -14,8 +12,7 @@ ASYNC110.py:7:5: ASYNC110 Use `trio.Event` instead of awaiting `trio.sleep` in a ASYNC110.py:12:5: ASYNC110 Use `trio.Event` instead of awaiting `trio.sleep` in a `while` loop | 11 | async def func(): -12 | while True: - | _____^ +12 | / while True: 13 | | await trio.sleep_until(10) | |__________________________________^ ASYNC110 | @@ -23,8 +20,7 @@ ASYNC110.py:12:5: ASYNC110 Use `trio.Event` instead of awaiting `trio.sleep` in ASYNC110.py:22:5: ASYNC110 Use `asyncio.Event` instead of awaiting `asyncio.sleep` in a `while` loop | 21 | async def func(): -22 | while True: - | _____^ +22 | / while True: 23 | | await anyio.sleep(10) | |_____________________________^ ASYNC110 | @@ -32,8 +28,7 @@ ASYNC110.py:22:5: ASYNC110 Use `asyncio.Event` instead of awaiting `asyncio.slee ASYNC110.py:27:5: ASYNC110 Use `asyncio.Event` instead of awaiting `asyncio.sleep` in a `while` loop | 26 | async def func(): -27 | while True: - | _____^ +27 | / while True: 28 | | await anyio.sleep_until(10) | |___________________________________^ ASYNC110 | @@ -41,8 +36,7 @@ ASYNC110.py:27:5: ASYNC110 Use `asyncio.Event` instead of awaiting `asyncio.slee ASYNC110.py:37:5: ASYNC110 Use `anyio.Event` instead of awaiting `anyio.sleep` in a `while` loop | 36 | async def func(): -37 | while True: - | _____^ +37 | / while True: 38 | | await asyncio.sleep(10) | |_______________________________^ ASYNC110 | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S608_S608.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S608_S608.py.snap index 6d0774dc656ed..59584d6ad7a94 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S608_S608.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S608_S608.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- S608.py:2:10: S608 Possible SQL injection vector through string-based query construction | @@ -46,14 +45,14 @@ S608.py:6:10: S608 Possible SQL injection vector through string-based query cons 5 | query4 = "SELECT {} FROM table;".format(var) 6 | query5 = f"SELECT * FROM table WHERE var = {var}" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -7 | +7 | 8 | query6 = "DELETE FROM table WHERE var = %s" % (var,) | S608.py:8:10: S608 Possible SQL injection vector through string-based query construction | 6 | query5 = f"SELECT * FROM table WHERE var = {var}" - 7 | + 7 | 8 | query6 = "DELETE FROM table WHERE var = %s" % (var,) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 9 | query7 = "DELETE FROM table WHERE VAR = " + var @@ -94,14 +93,14 @@ S608.py:12:11: S608 Possible SQL injection vector through string-based query con 11 | query9 = "DELETE FROM table WHERE var = {}".format(var) 12 | query10 = f"DELETE FROM table WHERE var = {var}" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -13 | +13 | 14 | query11 = "INSERT INTO table VALUES (%s)" % (var,) | S608.py:14:11: S608 Possible SQL injection vector through string-based query construction | 12 | query10 = f"DELETE FROM table WHERE var = {var}" -13 | +13 | 14 | query11 = "INSERT INTO table VALUES (%s)" % (var,) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 15 | query12 = "INSERT INTO TABLE VALUES (" + var + ")" @@ -132,14 +131,14 @@ S608.py:17:11: S608 Possible SQL injection vector through string-based query con 16 | query13 = "INSERT INTO {} VALUES ({})".format(table, var) 17 | query14 = f"INSERT INTO {table} VALUES var = {var}" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -18 | +18 | 19 | query15 = "UPDATE %s SET var = %s" % (table, var) | S608.py:19:11: S608 Possible SQL injection vector through string-based query construction | 17 | query14 = f"INSERT INTO {table} VALUES var = {var}" -18 | +18 | 19 | query15 = "UPDATE %s SET var = %s" % (table, var) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 20 | query16 = "UPDATE " + table + " SET var = " + var @@ -170,14 +169,14 @@ S608.py:22:11: S608 Possible SQL injection vector through string-based query con 21 | query17 = "UPDATE {} SET var = {}".format(table, var) 22 | query18 = f"UPDATE {table} SET var = {var}" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -23 | +23 | 24 | query19 = "select %s from table" % (var,) | S608.py:24:11: S608 Possible SQL injection vector through string-based query construction | 22 | query18 = f"UPDATE {table} SET var = {var}" -23 | +23 | 24 | query19 = "select %s from table" % (var,) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 25 | query20 = "select var from " + table @@ -218,14 +217,14 @@ S608.py:28:11: S608 Possible SQL injection vector through string-based query con 27 | query22 = "select {} from table;".format(var) 28 | query23 = f"select * from table where var = {var}" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -29 | +29 | 30 | query24 = "delete from table where var = %s" % (var,) | S608.py:30:11: S608 Possible SQL injection vector through string-based query construction | 28 | query23 = f"select * from table where var = {var}" -29 | +29 | 30 | query24 = "delete from table where var = %s" % (var,) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 31 | query25 = "delete from table where var = " + var @@ -266,14 +265,14 @@ S608.py:34:11: S608 Possible SQL injection vector through string-based query con 33 | query27 = "delete from table where var = {}".format(var) 34 | query28 = f"delete from table where var = {var}" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -35 | +35 | 36 | query29 = "insert into table values (%s)" % (var,) | S608.py:36:11: S608 Possible SQL injection vector through string-based query construction | 34 | query28 = f"delete from table where var = {var}" -35 | +35 | 36 | query29 = "insert into table values (%s)" % (var,) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 37 | query30 = "insert into table values (" + var + ")" @@ -304,14 +303,14 @@ S608.py:39:11: S608 Possible SQL injection vector through string-based query con 38 | query31 = "insert into {} values ({})".format(table, var) 39 | query32 = f"insert into {table} values var = {var}" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -40 | +40 | 41 | query33 = "update %s set var = %s" % (table, var) | S608.py:41:11: S608 Possible SQL injection vector through string-based query construction | 39 | query32 = f"insert into {table} values var = {var}" -40 | +40 | 41 | query33 = "update %s set var = %s" % (table, var) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 42 | query34 = "update " + table + " set var = " + var @@ -342,7 +341,7 @@ S608.py:44:11: S608 Possible SQL injection vector through string-based query con 43 | query35 = "update {} set var = {}".format(table, var) 44 | query36 = f"update {table} set var = {var}" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -45 | +45 | 46 | # multi-line failures | @@ -357,7 +356,7 @@ S608.py:48:12: S608 Possible SQL injection vector through string-based query con 51 | | WHERE var = %s 52 | | """ % var | |_____________^ S608 -53 | +53 | 54 | def query38(): | @@ -371,7 +370,7 @@ S608.py:55:12: S608 Possible SQL injection vector through string-based query con 58 | | WHERE var = 59 | | """ + var | |_____________^ S608 -60 | +60 | 61 | def query39(): | @@ -385,7 +384,7 @@ S608.py:62:12: S608 Possible SQL injection vector through string-based query con 65 | | WHERE var = {} 66 | | """.format(var) | |___________________^ S608 -67 | +67 | 68 | def query40(): | @@ -399,7 +398,7 @@ S608.py:69:12: S608 Possible SQL injection vector through string-based query con 72 | | WHERE var = {var} 73 | | """ | |_______^ S608 -74 | +74 | 75 | def query41(): | @@ -407,8 +406,7 @@ S608.py:77:9: S608 Possible SQL injection vector through string-based query cons | 75 | def query41(): 76 | return ( -77 | "SELECT * " - | _________^ +77 | / "SELECT * " 78 | | "FROM table " 79 | | f"WHERE var = {var}" | |____________________________^ S608 @@ -449,7 +447,7 @@ S608.py:86:30: S608 Possible SQL injection vector through string-based query con 85 | query44 = cursor.execute("SELECT * FROM table WHERE var = {}".format(var)) 86 | query45 = cursor.executemany("SELECT * FROM table WHERE var = %s" % var, []) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -87 | +87 | 88 | # # pass | @@ -458,7 +456,7 @@ S608.py:98:11: S608 Possible SQL injection vector through string-based query con 97 | # # INSERT without INTO (e.g. MySQL and derivatives) 98 | query46 = "INSERT table VALUES (%s)" % (var,) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 - 99 | + 99 | 100 | # # REPLACE (e.g. MySQL and derivatives, SQLite) | @@ -476,7 +474,7 @@ S608.py:102:11: S608 Possible SQL injection vector through string-based query co 101 | query47 = "REPLACE INTO table VALUES (%s)" % (var,) 102 | query48 = "REPLACE table VALUES (%s)" % (var,) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -103 | +103 | 104 | query49 = "Deselect something that is not SQL even though it has a ' from ' somewhere in %s." % "there" | @@ -494,7 +492,7 @@ S608.py:112:1: S608 Possible SQL injection vector through string-based query con 111 | "SELECT * FROM " + ("table1" if x > 0 else "table2") # query50 112 | "SELECT * FROM " + ("table1" if x > 0 else ["table2"]) # query51 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -113 | +113 | 114 | # test cases from #12044 | @@ -507,7 +505,7 @@ S608.py:117:12: S608 Possible SQL injection vector through string-based query co 119 | | FROM bar 120 | | """ | |_______^ S608 -121 | +121 | 122 | def query53(): | @@ -521,7 +519,7 @@ S608.py:123:12: S608 Possible SQL injection vector through string-based query co 126 | | FROM bar 127 | | """ | |_______^ S608 -128 | +128 | 129 | def query54(): | @@ -535,46 +533,46 @@ S608.py:130:12: S608 Possible SQL injection vector through string-based query co 133 | | bar 134 | | """ | |_______^ S608 -135 | +135 | 136 | query55 = f"""SELECT * FROM | S608.py:136:11: S608 Possible SQL injection vector through string-based query construction | 134 | """ -135 | +135 | 136 | query55 = f"""SELECT * FROM | ___________^ 137 | | {var}.table 138 | | """ | |___^ S608 -139 | +139 | 140 | query56 = f"""SELECT * | S608.py:140:11: S608 Possible SQL injection vector through string-based query construction | 138 | """ -139 | +139 | 140 | query56 = f"""SELECT * | ___________^ 141 | | FROM {var}.table 142 | | """ | |___^ S608 -143 | +143 | 144 | query57 = f""" | S608.py:144:11: S608 Possible SQL injection vector through string-based query construction | 142 | """ -143 | +143 | 144 | query57 = f""" | ___________^ 145 | | SELECT * 146 | | FROM {var}.table 147 | | """ | |___^ S608 -148 | +148 | 149 | query57 = f""" | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B027_B027.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B027_B027.py.snap index e818056d0a618..371a87144bbd2 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B027_B027.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B027_B027.py.snap @@ -1,55 +1,50 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- B027.py:18:5: B027 `AbstractClass.empty_1` is an empty method in an abstract base class, but has no abstract decorator | 17 | class AbstractClass(ABC): -18 | def empty_1(self): # error - | _____^ +18 | / def empty_1(self): # error 19 | | ... | |___________^ B027 -20 | +20 | 21 | def empty_2(self): # error | B027.py:21:5: B027 `AbstractClass.empty_2` is an empty method in an abstract base class, but has no abstract decorator | 19 | ... -20 | -21 | def empty_2(self): # error - | _____^ +20 | +21 | / def empty_2(self): # error 22 | | pass | |____________^ B027 -23 | +23 | 24 | def empty_3(self): # error | B027.py:24:5: B027 `AbstractClass.empty_3` is an empty method in an abstract base class, but has no abstract decorator | 22 | pass -23 | -24 | def empty_3(self): # error - | _____^ +23 | +24 | / def empty_3(self): # error 25 | | """docstring""" 26 | | ... | |___________^ B027 -27 | +27 | 28 | def empty_4(self): # error | B027.py:28:5: B027 `AbstractClass.empty_4` is an empty method in an abstract base class, but has no abstract decorator | 26 | ... -27 | -28 | def empty_4(self): # error - | _____^ +27 | +28 | / def empty_4(self): # error 29 | | """multiple ellipsis/pass""" 30 | | ... 31 | | pass 32 | | ... 33 | | pass | |____________^ B027 -34 | +34 | 35 | @notabstract | diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C419_C419.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C419_C419.py.snap index 24c721a492dff..25ff5019b4b29 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C419_C419.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C419_C419.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs -snapshot_kind: text --- C419.py:1:5: C419 [*] Unnecessary list comprehension | @@ -84,7 +83,7 @@ C419.py:9:5: C419 [*] Unnecessary set comprehension 8 | ) # third comment 9 | any({x.id for x in bar}) | ^^^^^^^^^^^^^^^^^^^ C419 -10 | +10 | 11 | # OK | = help: Remove unnecessary comprehension @@ -103,8 +102,7 @@ C419.py:28:5: C419 [*] Unnecessary list comprehension | 26 | # Special comment handling 27 | any( -28 | [ # lbracket comment - | _____^ +28 | / [ # lbracket comment 29 | | # second line comment 30 | | i.bit_count() 31 | | # random middle comment @@ -189,7 +187,7 @@ C419.py:50:5: C419 [*] Unnecessary set comprehension 49 | any({x.id for x in bar}) 50 | all({x.id for x in bar}) | ^^^^^^^^^^^^^^^^^^^ C419 -51 | +51 | 52 | # should be linted in preview... | = help: Remove unnecessary comprehension diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__preview__C419_C419_1.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__preview__C419_C419_1.py.snap index efdfa04c4d221..c3433692feb3a 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__preview__C419_C419_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__preview__C419_C419_1.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs -snapshot_kind: text --- C419_1.py:1:5: C419 [*] Unnecessary list comprehension | @@ -61,7 +60,7 @@ C419_1.py:4:5: C419 [*] Unnecessary list comprehension 3 | max([x.val for x in bar]) 4 | sum([x.val for x in bar], 0) | ^^^^^^^^^^^^^^^^^^^^ C419 -5 | +5 | 6 | # OK | = help: Remove unnecessary comprehension @@ -80,8 +79,7 @@ C419_1.py:14:5: C419 [*] Unnecessary list comprehension | 12 | # Multi-line 13 | sum( -14 | [ - | _____^ +14 | / [ 15 | | delta 16 | | for delta in timedelta_list 17 | | if delta diff --git a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ012_DJ012.py.snap b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ012_DJ012.py.snap index 5729bd6701af1..8b124c4474f45 100644 --- a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ012_DJ012.py.snap +++ b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ012_DJ012.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_django/mod.rs -snapshot_kind: text --- DJ012.py:28:5: DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: field declaration should come before `Meta` class | 26 | return "foobar" -27 | +27 | 28 | first_name = models.CharField(max_length=32) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ012 | @@ -13,7 +12,7 @@ DJ012.py:28:5: DJ012 Order of model's inner classes, methods, and fields does no DJ012.py:43:5: DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: field declaration should come before manager declaration | 41 | return "foobar" -42 | +42 | 43 | first_name = models.CharField(max_length=32) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ012 | @@ -21,9 +20,8 @@ DJ012.py:43:5: DJ012 Order of model's inner classes, methods, and fields does no DJ012.py:56:5: DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: Magic method should come before custom method | 54 | pass -55 | -56 | def __str__(self): - | _____^ +55 | +56 | / def __str__(self): 57 | | return "foobar" | |_______________________^ DJ012 | @@ -31,9 +29,8 @@ DJ012.py:56:5: DJ012 Order of model's inner classes, methods, and fields does no DJ012.py:69:5: DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: `save` method should come before `get_absolute_url` method | 67 | pass -68 | -69 | def save(self): - | _____^ +68 | +69 | / def save(self): 70 | | pass | |____________^ DJ012 | @@ -41,7 +38,7 @@ DJ012.py:69:5: DJ012 Order of model's inner classes, methods, and fields does no DJ012.py:123:5: DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: field declaration should come before `Meta` class | 121 | verbose_name = "test" -122 | +122 | 123 | first_name = models.CharField(max_length=32) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ012 124 | last_name = models.CharField(max_length=32) @@ -50,7 +47,7 @@ DJ012.py:123:5: DJ012 Order of model's inner classes, methods, and fields does n DJ012.py:129:5: DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: field declaration should come before `Meta` class | 127 | pass -128 | +128 | 129 | middle_name = models.CharField(max_length=32) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ012 | @@ -58,7 +55,7 @@ DJ012.py:129:5: DJ012 Order of model's inner classes, methods, and fields does n DJ012.py:146:5: DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: field declaration should come before `Meta` class | 144 | return "foobar" -145 | +145 | 146 | first_name = models.CharField(max_length=32) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ012 | diff --git a/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__custom.snap b/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__custom.snap index 105d0fe855735..bb2dfde20bc68 100644 --- a/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__custom.snap +++ b/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__custom.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_errmsg/mod.rs -snapshot_kind: text --- EM.py:5:24: EM101 [*] Exception must not use a string literal, assign to variable first | @@ -83,7 +82,7 @@ EM.py:32:24: EM101 [*] Exception must not use a string literal, assign to variab EM.py:39:24: EM101 [*] Exception must not use a string literal, assign to variable first | 37 | msg = "hello" -38 | +38 | 39 | raise RuntimeError("This is an example exception") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 | @@ -223,8 +222,7 @@ EM.py:76:9: EM103 [*] Exception must not use a `.format()` string directly, assi | 74 | def f_multi_line_string2(): 75 | raise RuntimeError( -76 | "This is an {example} exception".format( - | _________^ +76 | / "This is an {example} exception".format( 77 | | example="example" 78 | | ) | |_________^ EM103 @@ -253,8 +251,7 @@ EM.py:84:9: EM103 [*] Exception must not use a `.format()` string directly, assi | 82 | def f_multi_line_string2(): 83 | raise RuntimeError( -84 | ( - | _________^ +84 | / ( 85 | | "This is an " 86 | | "{example} exception" 87 | | ).format( diff --git a/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__defaults.snap b/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__defaults.snap index b073d4fdd38d2..42e9f412505e0 100644 --- a/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__defaults.snap +++ b/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__defaults.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_errmsg/mod.rs -snapshot_kind: text --- EM.py:5:24: EM101 [*] Exception must not use a string literal, assign to variable first | @@ -121,7 +120,7 @@ EM.py:32:24: EM101 [*] Exception must not use a string literal, assign to variab EM.py:39:24: EM101 [*] Exception must not use a string literal, assign to variable first | 37 | msg = "hello" -38 | +38 | 39 | raise RuntimeError("This is an example exception") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 | @@ -261,8 +260,7 @@ EM.py:69:9: EM101 [*] Exception must not use a string literal, assign to variabl | 67 | def f_multi_line_string(): 68 | raise RuntimeError( -69 | "first" - | _________^ +69 | / "first" 70 | | "second" | |________________^ EM101 71 | ) @@ -289,8 +287,7 @@ EM.py:76:9: EM103 [*] Exception must not use a `.format()` string directly, assi | 74 | def f_multi_line_string2(): 75 | raise RuntimeError( -76 | "This is an {example} exception".format( - | _________^ +76 | / "This is an {example} exception".format( 77 | | example="example" 78 | | ) | |_________^ EM103 @@ -319,8 +316,7 @@ EM.py:84:9: EM103 [*] Exception must not use a `.format()` string directly, assi | 82 | def f_multi_line_string2(): 83 | raise RuntimeError( -84 | ( - | _________^ +84 | / ( 85 | | "This is an " 86 | | "{example} exception" 87 | | ).format( diff --git a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC003_ISC.py.snap b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC003_ISC.py.snap index 2cac295f82b2b..dccaf146a2f4f 100644 --- a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC003_ISC.py.snap +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC003_ISC.py.snap @@ -1,12 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs -snapshot_kind: text --- ISC.py:9:3: ISC003 Explicitly concatenated string should be implicitly concatenated | 8 | _ = ( - 9 | "abc" + - | ___^ + 9 | / "abc" + 10 | | "def" | |_______^ ISC003 11 | ) @@ -15,8 +13,7 @@ ISC.py:9:3: ISC003 Explicitly concatenated string should be implicitly concatena ISC.py:14:3: ISC003 Explicitly concatenated string should be implicitly concatenated | 13 | _ = ( -14 | f"abc" + - | ___^ +14 | / f"abc" + 15 | | "def" | |_______^ ISC003 16 | ) @@ -25,8 +22,7 @@ ISC.py:14:3: ISC003 Explicitly concatenated string should be implicitly concaten ISC.py:19:3: ISC003 Explicitly concatenated string should be implicitly concatenated | 18 | _ = ( -19 | b"abc" + - | ___^ +19 | / b"abc" + 20 | | b"def" | |________^ ISC003 21 | ) @@ -51,6 +47,6 @@ ISC.py:80:10: ISC003 Explicitly concatenated string should be implicitly concate | __________^ 81 | | + f"second"} d" | |_______________^ ISC003 -82 | +82 | 83 | # See https://github.com/astral-sh/ruff/issues/12936 | diff --git a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC002_ISC.py.snap b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC002_ISC.py.snap index ad92f27fe6516..a468ebd279a16 100644 --- a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC002_ISC.py.snap +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC002_ISC.py.snap @@ -1,24 +1,22 @@ --- source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs -snapshot_kind: text --- ISC.py:5:5: ISC002 Implicitly concatenated string literals over multiple lines | 3 | _ = "abc" + "def" -4 | +4 | 5 | _ = "abc" \ | _____^ 6 | | "def" | |_________^ ISC002 -7 | +7 | 8 | _ = ( | ISC.py:24:3: ISC002 Implicitly concatenated string literals over multiple lines | 23 | _ = ( -24 | "abc" - | ___^ +24 | / "abc" 25 | | "def" | |_______^ ISC002 26 | ) @@ -27,8 +25,7 @@ ISC.py:24:3: ISC002 Implicitly concatenated string literals over multiple lines ISC.py:29:3: ISC002 Implicitly concatenated string literals over multiple lines | 28 | _ = ( -29 | f"abc" - | ___^ +29 | / f"abc" 30 | | "def" | |_______^ ISC002 31 | ) @@ -37,8 +34,7 @@ ISC.py:29:3: ISC002 Implicitly concatenated string literals over multiple lines ISC.py:34:3: ISC002 Implicitly concatenated string literals over multiple lines | 33 | _ = ( -34 | b"abc" - | ___^ +34 | / b"abc" 35 | | b"def" | |________^ ISC002 36 | ) @@ -48,8 +44,7 @@ ISC.py:67:5: ISC002 Implicitly concatenated string literals over multiple lines | 65 | _ = f"""abc {"def" "ghi"} jkl""" 66 | _ = f"""abc { -67 | "def" - | _____^ +67 | / "def" 68 | | "ghi" | |_________^ ISC002 69 | } jkl""" @@ -63,6 +58,6 @@ ISC.py:74:10: ISC002 Implicitly concatenated string literals over multiple lines | __________^ 75 | | f"def"} g" | |__________^ ISC002 -76 | +76 | 77 | # Explicitly concatenated nested f-strings | diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE800_PIE800.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE800_PIE800.py.snap index 65449396c05c5..393e7d05f137c 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE800_PIE800.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE800_PIE800.py.snap @@ -13,9 +13,9 @@ PIE800.py:1:14: PIE800 [*] Unnecessary spread `**` ℹ Safe fix 1 |-{"foo": 1, **{"bar": 1}} # PIE800 1 |+{"foo": 1, "bar": 1} # PIE800 -2 2 | +2 2 | 3 3 | {**{"bar": 10}, "a": "b"} # PIE800 -4 4 | +4 4 | PIE800.py:3:4: PIE800 [*] Unnecessary spread `**` | @@ -30,12 +30,12 @@ PIE800.py:3:4: PIE800 [*] Unnecessary spread `**` ℹ Safe fix 1 1 | {"foo": 1, **{"bar": 1}} # PIE800 -2 2 | +2 2 | 3 |-{**{"bar": 10}, "a": "b"} # PIE800 3 |+{"bar": 10, "a": "b"} # PIE800 -4 4 | +4 4 | 5 5 | foo({**foo, **{"bar": True}}) # PIE800 -6 6 | +6 6 | PIE800.py:5:15: PIE800 [*] Unnecessary spread `**` | @@ -49,14 +49,14 @@ PIE800.py:5:15: PIE800 [*] Unnecessary spread `**` = help: Remove unnecessary dict ℹ Safe fix -2 2 | +2 2 | 3 3 | {**{"bar": 10}, "a": "b"} # PIE800 -4 4 | +4 4 | 5 |-foo({**foo, **{"bar": True}}) # PIE800 5 |+foo({**foo, "bar": True}) # PIE800 -6 6 | +6 6 | 7 7 | {**foo, **{"bar": 10}} # PIE800 -8 8 | +8 8 | PIE800.py:7:11: PIE800 [*] Unnecessary spread `**` | @@ -70,12 +70,12 @@ PIE800.py:7:11: PIE800 [*] Unnecessary spread `**` = help: Remove unnecessary dict ℹ Safe fix -4 4 | +4 4 | 5 5 | foo({**foo, **{"bar": True}}) # PIE800 -6 6 | +6 6 | 7 |-{**foo, **{"bar": 10}} # PIE800 7 |+{**foo, "bar": 10} # PIE800 -8 8 | +8 8 | 9 9 | { # PIE800 10 10 | "a": "b", @@ -99,7 +99,7 @@ PIE800.py:12:7: PIE800 [*] Unnecessary spread `**` 10 10 | "a": "b", 11 11 | # Preserve 12 |- **{ - 12 |+ + 12 |+ 13 13 | # all 14 |- "bar": 10, # the 14 |+ "bar": 10 # the @@ -107,7 +107,7 @@ PIE800.py:12:7: PIE800 [*] Unnecessary spread `**` 16 |- }, 16 |+ , 17 17 | } -18 18 | +18 18 | 19 19 | {**foo, **buzz, **{bar: 10}} # PIE800 PIE800.py:19:19: PIE800 [*] Unnecessary spread `**` @@ -124,10 +124,10 @@ PIE800.py:19:19: PIE800 [*] Unnecessary spread `**` ℹ Safe fix 16 16 | }, 17 17 | } -18 18 | +18 18 | 19 |-{**foo, **buzz, **{bar: 10}} # PIE800 19 |+{**foo, **buzz, bar: 10} # PIE800 -20 20 | +20 20 | 21 21 | # https://github.com/astral-sh/ruff/issues/15366 22 22 | { @@ -148,15 +148,14 @@ PIE800.py:24:8: PIE800 [*] Unnecessary spread `**` 24 |- **({"count": 1 if include_count else {}}), 24 |+ "count": 1 if include_count else {}, 25 25 | } -26 26 | +26 26 | 27 27 | { PIE800.py:30:9: PIE800 [*] Unnecessary spread `**` | 28 | "data": [], 29 | **( # Comment -30 | { # Comment - | _________^ +30 | / { # Comment 31 | | "count": 1 if include_count else {}}), | |________________________________________________^ PIE800 32 | } @@ -164,7 +163,7 @@ PIE800.py:30:9: PIE800 [*] Unnecessary spread `**` = help: Remove unnecessary dict ℹ Safe fix -26 26 | +26 26 | 27 27 | { 28 28 | "data": [], 29 |- **( # Comment @@ -174,15 +173,14 @@ PIE800.py:30:9: PIE800 [*] Unnecessary spread `**` 30 |+ # Comment 31 |+ "count": 1 if include_count else {}, 32 32 | } -33 33 | +33 33 | 34 34 | { PIE800.py:37:9: PIE800 [*] Unnecessary spread `**` | 35 | "data": [], 36 | **( -37 | { - | _________^ +37 | / { 38 | | "count": (a := 1),}), | |_______________________________^ PIE800 39 | } @@ -190,25 +188,24 @@ PIE800.py:37:9: PIE800 [*] Unnecessary spread `**` = help: Remove unnecessary dict ℹ Safe fix -33 33 | +33 33 | 34 34 | { 35 35 | "data": [], 36 |- **( 37 |- { 38 |- "count": (a := 1),}), - 36 |+ - 37 |+ + 36 |+ + 37 |+ 38 |+ "count": (a := 1), 39 39 | } -40 40 | +40 40 | 41 41 | { PIE800.py:44:9: PIE800 [*] Unnecessary spread `**` | 42 | "data": [], 43 | **( -44 | { - | _________^ +44 | / { 45 | | "count": (a := 1) 46 | | } | |_____________^ PIE800 @@ -218,28 +215,27 @@ PIE800.py:44:9: PIE800 [*] Unnecessary spread `**` = help: Remove unnecessary dict ℹ Safe fix -40 40 | +40 40 | 41 41 | { 42 42 | "data": [], 43 |- **( 44 |- { - 43 |+ - 44 |+ + 43 |+ + 44 |+ 45 45 | "count": (a := 1) 46 |- } 47 |- ) - 46 |+ - 47 |+ + 46 |+ + 47 |+ 48 48 | , 49 49 | } -50 50 | +50 50 | PIE800.py:54:9: PIE800 [*] Unnecessary spread `**` | 52 | "data": [], 53 | **( -54 | { - | _________^ +54 | / { 55 | | "count": (a := 1), # Comment 56 | | } # Comment | |_____________^ PIE800 @@ -249,7 +245,7 @@ PIE800.py:54:9: PIE800 [*] Unnecessary spread `**` = help: Remove unnecessary dict ℹ Safe fix -50 50 | +50 50 | 51 51 | { 52 52 | "data": [], 53 |- **( @@ -257,14 +253,14 @@ PIE800.py:54:9: PIE800 [*] Unnecessary spread `**` 55 |- "count": (a := 1), # Comment 56 |- } # Comment 57 |- ) # Comment - 53 |+ - 54 |+ + 53 |+ + 54 |+ 55 |+ "count": (a := 1) # Comment 56 |+ # Comment 57 |+ # Comment 58 58 | , 59 59 | } -60 60 | +60 60 | PIE800.py:65:1: PIE800 [*] Unnecessary spread `**` | @@ -280,7 +276,7 @@ PIE800.py:65:1: PIE800 [*] Unnecessary spread `**` = help: Remove unnecessary dict ℹ Safe fix -60 60 | +60 60 | 61 61 | ({ 62 62 | "data": [], 63 |- **( # Comment @@ -295,7 +291,7 @@ PIE800.py:65:1: PIE800 [*] Unnecessary spread `**` 65 |+ # Comment 66 |+ "count": (a := 1) # Comment 67 |+ # Comment - 68 |+ + 68 |+ 69 |+ # Comment 70 70 | , 71 71 | }) diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.py.snap index 2133baee9e4d2..3d671d859c533 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.py.snap @@ -6,7 +6,7 @@ PYI016.py:7:15: PYI016 [*] Duplicate union member `str` 6 | # Should emit for duplicate field types. 7 | field2: str | str # PYI016: Duplicate union member `str` | ^^^ PYI016 -8 | +8 | 9 | # Should emit for union types in arguments. | = help: Remove duplicate union member `str` @@ -126,7 +126,7 @@ PYI016.py:21:28: PYI016 [*] Duplicate union member `int` 20 | field5: str | int | str # PYI016: Duplicate union member `str` 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` | ^^^ PYI016 -22 | +22 | 23 | # Shouldn't emit for non-type unions. | = help: Remove duplicate union member `int` @@ -146,7 +146,7 @@ PYI016.py:27:22: PYI016 [*] Duplicate union member `int` 26 | # Should emit for strangely-bracketed unions. 27 | field8: int | (str | int) # PYI016: Duplicate union member `int` | ^^^ PYI016 -28 | +28 | 29 | # Should handle user brackets when fixing. | = help: Remove duplicate union member `int` @@ -186,7 +186,7 @@ PYI016.py:31:24: PYI016 [*] Duplicate union member `str` 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` | ^^^ PYI016 -32 | +32 | 33 | # Should emit for nested unions. | = help: Remove duplicate union member `str` @@ -206,7 +206,7 @@ PYI016.py:34:21: PYI016 [*] Duplicate union member `int` 33 | # Should emit for nested unions. 34 | field11: dict[int | int, str] | ^^^ PYI016 -35 | +35 | 36 | # Should emit for unions with more than two cases | = help: Remove duplicate union member `int` @@ -265,7 +265,7 @@ PYI016.py:38:16: PYI016 [*] Duplicate union member `int` 37 | field12: int | int | int # Error 38 | field13: int | int | int | int # Error | ^^^ PYI016 -39 | +39 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent | = help: Remove duplicate union member `int` @@ -286,7 +286,7 @@ PYI016.py:38:22: PYI016 [*] Duplicate union member `int` 37 | field12: int | int | int # Error 38 | field13: int | int | int | int # Error | ^^^ PYI016 -39 | +39 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent | = help: Remove duplicate union member `int` @@ -307,7 +307,7 @@ PYI016.py:38:28: PYI016 [*] Duplicate union member `int` 37 | field12: int | int | int # Error 38 | field13: int | int | int | int # Error | ^^^ PYI016 -39 | +39 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent | = help: Remove duplicate union member `int` @@ -327,7 +327,7 @@ PYI016.py:41:16: PYI016 [*] Duplicate union member `int` 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 | field14: int | int | str | int # Error | ^^^ PYI016 -42 | +42 | 43 | # Should emit for duplicate literal types; also covered by PYI030 | = help: Remove duplicate union member `int` @@ -347,7 +347,7 @@ PYI016.py:41:28: PYI016 [*] Duplicate union member `int` 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 | field14: int | int | str | int # Error | ^^^ PYI016 -42 | +42 | 43 | # Should emit for duplicate literal types; also covered by PYI030 | = help: Remove duplicate union member `int` @@ -367,7 +367,7 @@ PYI016.py:44:30: PYI016 [*] Duplicate union member `typing.Literal[1]` 43 | # Should emit for duplicate literal types; also covered by PYI030 44 | field15: typing.Literal[1] | typing.Literal[1] # Error | ^^^^^^^^^^^^^^^^^ PYI016 -45 | +45 | 46 | # Shouldn't emit if in new parent type | = help: Remove duplicate union member `typing.Literal[1]` @@ -386,8 +386,7 @@ PYI016.py:57:5: PYI016 [*] Duplicate union member `set[int]` | 55 | int # foo 56 | ], -57 | set[ - | _____^ +57 | / set[ 58 | | int # bar 59 | | ], | |_____^ PYI016 @@ -417,7 +416,7 @@ PYI016.py:63:28: PYI016 [*] Duplicate union member `int` 62 | # Should emit in cases with `typing.Union` instead of `|` 63 | field19: typing.Union[int, int] # Error | ^^^ PYI016 -64 | +64 | 65 | # Should emit in cases with nested `typing.Union` | = help: Remove duplicate union member `int` @@ -437,7 +436,7 @@ PYI016.py:66:41: PYI016 [*] Duplicate union member `int` 65 | # Should emit in cases with nested `typing.Union` 66 | field20: typing.Union[int, typing.Union[int, str]] # Error | ^^^ PYI016 -67 | +67 | 68 | # Should emit in cases with mixed `typing.Union` and `|` | = help: Remove duplicate union member `int` @@ -457,7 +456,7 @@ PYI016.py:69:28: PYI016 [*] Duplicate union member `int` 68 | # Should emit in cases with mixed `typing.Union` and `|` 69 | field21: typing.Union[int, int | str] # Error | ^^^ PYI016 -70 | +70 | 71 | # Should emit only once in cases with multiple nested `typing.Union` | = help: Remove duplicate union member `int` @@ -477,7 +476,7 @@ PYI016.py:72:41: PYI016 [*] Duplicate union member `int` 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error | ^^^ PYI016 -73 | +73 | 74 | # Should emit in cases with newlines | = help: Remove duplicate union member `int` @@ -497,7 +496,7 @@ PYI016.py:72:59: PYI016 [*] Duplicate union member `int` 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error | ^^^ PYI016 -73 | +73 | 74 | # Should emit in cases with newlines | = help: Remove duplicate union member `int` @@ -517,7 +516,7 @@ PYI016.py:72:64: PYI016 [*] Duplicate union member `int` 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error | ^^^ PYI016 -73 | +73 | 74 | # Should emit in cases with newlines | = help: Remove duplicate union member `int` @@ -538,7 +537,7 @@ PYI016.py:76:12: PYI016 [*] Duplicate union member `set[int]` 75 | field23: set[ # foo 76 | int] | set[int] | ^^^^^^^^ PYI016 -77 | +77 | 78 | # Should emit twice (once for each `int` in the nested union, both of which are | = help: Remove duplicate union member `set[int]` @@ -560,7 +559,7 @@ PYI016.py:81:41: PYI016 [*] Duplicate union member `int` 80 | # we incorrectly re-checked the nested union). 81 | field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` | ^^^ PYI016 -82 | +82 | 83 | # Should emit twice (once for each `int` in the nested union, both of which are | = help: Remove duplicate union member `int` @@ -581,7 +580,7 @@ PYI016.py:81:46: PYI016 [*] Duplicate union member `int` 80 | # we incorrectly re-checked the nested union). 81 | field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` | ^^^ PYI016 -82 | +82 | 83 | # Should emit twice (once for each `int` in the nested union, both of which are | = help: Remove duplicate union member `int` @@ -602,7 +601,7 @@ PYI016.py:86:28: PYI016 [*] Duplicate union member `int` 85 | # we incorrectly re-checked the nested union). 86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` | ^^^ PYI016 -87 | +87 | 88 | # Should emit in cases with nested `typing.Union` | = help: Remove duplicate union member `int` @@ -623,7 +622,7 @@ PYI016.py:86:34: PYI016 [*] Duplicate union member `int` 85 | # we incorrectly re-checked the nested union). 86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` | ^^^ PYI016 -87 | +87 | 88 | # Should emit in cases with nested `typing.Union` | = help: Remove duplicate union member `int` @@ -643,7 +642,7 @@ PYI016.py:89:41: PYI016 [*] Duplicate union member `int` 88 | # Should emit in cases with nested `typing.Union` 89 | field26: typing.Union[typing.Union[int, int]] # PYI016: Duplicate union member `int` | ^^^ PYI016 -90 | +90 | 91 | # Should emit in cases with nested `typing.Union` | = help: Remove duplicate union member `int` @@ -663,7 +662,7 @@ PYI016.py:92:54: PYI016 [*] Duplicate union member `int` 91 | # Should emit in cases with nested `typing.Union` 92 | field27: typing.Union[typing.Union[typing.Union[int, int]]] # PYI016: Duplicate union member `int` | ^^^ PYI016 -93 | +93 | 94 | # Should emit in cases with mixed `typing.Union` and `|` | = help: Remove duplicate union member `int` @@ -683,7 +682,7 @@ PYI016.py:95:29: PYI016 [*] Duplicate union member `int` 94 | # Should emit in cases with mixed `typing.Union` and `|` 95 | field28: typing.Union[int | int] # Error | ^^^ PYI016 -96 | +96 | 97 | # Should emit twice in cases with multiple nested `typing.Union` | = help: Remove duplicate union member `int` @@ -703,7 +702,7 @@ PYI016.py:98:54: PYI016 [*] Duplicate union member `int` 97 | # Should emit twice in cases with multiple nested `typing.Union` 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error | ^^^ PYI016 - 99 | + 99 | 100 | # Should emit once in cases with multiple nested `typing.Union` | = help: Remove duplicate union member `int` @@ -723,7 +722,7 @@ PYI016.py:98:59: PYI016 [*] Duplicate union member `int` 97 | # Should emit twice in cases with multiple nested `typing.Union` 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error | ^^^ PYI016 - 99 | + 99 | 100 | # Should emit once in cases with multiple nested `typing.Union` | = help: Remove duplicate union member `int` @@ -743,7 +742,7 @@ PYI016.py:101:54: PYI016 [*] Duplicate union member `int` 100 | # Should emit once in cases with multiple nested `typing.Union` 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]] # Error | ^^^ PYI016 -102 | +102 | 103 | # Should emit once, and fix to `typing.Union[float, int]` | = help: Remove duplicate union member `int` @@ -763,7 +762,7 @@ PYI016.py:104:49: PYI016 [*] Duplicate union member `int` 103 | # Should emit once, and fix to `typing.Union[float, int]` 104 | field31: typing.Union[float, typing.Union[int | int]] # Error | ^^^ PYI016 -105 | +105 | 106 | # Should emit once, and fix to `typing.Union[float, int]` | = help: Remove duplicate union member `int` @@ -783,7 +782,7 @@ PYI016.py:107:49: PYI016 [*] Duplicate union member `int` 106 | # Should emit once, and fix to `typing.Union[float, int]` 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error | ^^^ PYI016 -108 | +108 | 109 | # Test case for mixed union type fix | = help: Remove duplicate union member `int` @@ -803,7 +802,7 @@ PYI016.py:107:55: PYI016 [*] Duplicate union member `int` 106 | # Should emit once, and fix to `typing.Union[float, int]` 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error | ^^^ PYI016 -108 | +108 | 109 | # Test case for mixed union type fix | = help: Remove duplicate union member `int` @@ -823,7 +822,7 @@ PYI016.py:110:42: PYI016 [*] Duplicate union member `int` 109 | # Test case for mixed union type fix 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error | ^^^ PYI016 -111 | +111 | 112 | # Test case for mixed union type | = help: Remove duplicate union member `int` @@ -843,7 +842,7 @@ PYI016.py:110:62: PYI016 [*] Duplicate union member `int` 109 | # Test case for mixed union type fix 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error | ^^^ PYI016 -111 | +111 | 112 | # Test case for mixed union type | = help: Remove duplicate union member `int` @@ -863,7 +862,7 @@ PYI016.py:110:68: PYI016 [*] Duplicate union member `int` 109 | # Test case for mixed union type fix 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error | ^^^ PYI016 -111 | +111 | 112 | # Test case for mixed union type | = help: Remove duplicate union member `int` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.pyi.snap index 1cdbef03b7d7a..0f14b06acb8d6 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.pyi.snap @@ -7,7 +7,7 @@ PYI016.pyi:7:15: PYI016 [*] Duplicate union member `str` 6 | # Should emit for duplicate field types. 7 | field2: str | str # PYI016: Duplicate union member `str` | ^^^ PYI016 -8 | +8 | 9 | # Should emit for union types in arguments. | = help: Remove duplicate union member `str` @@ -127,7 +127,7 @@ PYI016.pyi:21:28: PYI016 [*] Duplicate union member `int` 20 | field5: str | int | str # PYI016: Duplicate union member `str` 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` | ^^^ PYI016 -22 | +22 | 23 | # Shouldn't emit for non-type unions. | = help: Remove duplicate union member `int` @@ -147,7 +147,7 @@ PYI016.pyi:27:22: PYI016 [*] Duplicate union member `int` 26 | # Should emit for strangely-bracketed unions. 27 | field8: int | (str | int) # PYI016: Duplicate union member `int` | ^^^ PYI016 -28 | +28 | 29 | # Should handle user brackets when fixing. | = help: Remove duplicate union member `int` @@ -187,7 +187,7 @@ PYI016.pyi:31:24: PYI016 [*] Duplicate union member `str` 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` | ^^^ PYI016 -32 | +32 | 33 | # Should emit for nested unions. | = help: Remove duplicate union member `str` @@ -207,7 +207,7 @@ PYI016.pyi:34:21: PYI016 [*] Duplicate union member `int` 33 | # Should emit for nested unions. 34 | field11: dict[int | int, str] | ^^^ PYI016 -35 | +35 | 36 | # Should emit for unions with more than two cases | = help: Remove duplicate union member `int` @@ -266,7 +266,7 @@ PYI016.pyi:38:16: PYI016 [*] Duplicate union member `int` 37 | field12: int | int | int # Error 38 | field13: int | int | int | int # Error | ^^^ PYI016 -39 | +39 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent | = help: Remove duplicate union member `int` @@ -287,7 +287,7 @@ PYI016.pyi:38:22: PYI016 [*] Duplicate union member `int` 37 | field12: int | int | int # Error 38 | field13: int | int | int | int # Error | ^^^ PYI016 -39 | +39 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent | = help: Remove duplicate union member `int` @@ -308,7 +308,7 @@ PYI016.pyi:38:28: PYI016 [*] Duplicate union member `int` 37 | field12: int | int | int # Error 38 | field13: int | int | int | int # Error | ^^^ PYI016 -39 | +39 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent | = help: Remove duplicate union member `int` @@ -328,7 +328,7 @@ PYI016.pyi:41:16: PYI016 [*] Duplicate union member `int` 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 | field14: int | int | str | int # Error | ^^^ PYI016 -42 | +42 | 43 | # Should emit for duplicate literal types; also covered by PYI030 | = help: Remove duplicate union member `int` @@ -348,7 +348,7 @@ PYI016.pyi:41:28: PYI016 [*] Duplicate union member `int` 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 | field14: int | int | str | int # Error | ^^^ PYI016 -42 | +42 | 43 | # Should emit for duplicate literal types; also covered by PYI030 | = help: Remove duplicate union member `int` @@ -368,7 +368,7 @@ PYI016.pyi:44:30: PYI016 [*] Duplicate union member `typing.Literal[1]` 43 | # Should emit for duplicate literal types; also covered by PYI030 44 | field15: typing.Literal[1] | typing.Literal[1] # Error | ^^^^^^^^^^^^^^^^^ PYI016 -45 | +45 | 46 | # Shouldn't emit if in new parent type | = help: Remove duplicate union member `typing.Literal[1]` @@ -387,8 +387,7 @@ PYI016.pyi:57:5: PYI016 [*] Duplicate union member `set[int]` | 55 | int # foo 56 | ], -57 | set[ - | _____^ +57 | / set[ 58 | | int # bar 59 | | ], | |_____^ PYI016 @@ -418,7 +417,7 @@ PYI016.pyi:63:28: PYI016 [*] Duplicate union member `int` 62 | # Should emit in cases with `typing.Union` instead of `|` 63 | field19: typing.Union[int, int] # Error | ^^^ PYI016 -64 | +64 | 65 | # Should emit in cases with nested `typing.Union` | = help: Remove duplicate union member `int` @@ -438,7 +437,7 @@ PYI016.pyi:66:41: PYI016 [*] Duplicate union member `int` 65 | # Should emit in cases with nested `typing.Union` 66 | field20: typing.Union[int, typing.Union[int, str]] # Error | ^^^ PYI016 -67 | +67 | 68 | # Should emit in cases with mixed `typing.Union` and `|` | = help: Remove duplicate union member `int` @@ -458,7 +457,7 @@ PYI016.pyi:69:28: PYI016 [*] Duplicate union member `int` 68 | # Should emit in cases with mixed `typing.Union` and `|` 69 | field21: typing.Union[int, int | str] # Error | ^^^ PYI016 -70 | +70 | 71 | # Should emit only once in cases with multiple nested `typing.Union` | = help: Remove duplicate union member `int` @@ -478,7 +477,7 @@ PYI016.pyi:72:41: PYI016 [*] Duplicate union member `int` 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error | ^^^ PYI016 -73 | +73 | 74 | # Should emit in cases with newlines | = help: Remove duplicate union member `int` @@ -498,7 +497,7 @@ PYI016.pyi:72:59: PYI016 [*] Duplicate union member `int` 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error | ^^^ PYI016 -73 | +73 | 74 | # Should emit in cases with newlines | = help: Remove duplicate union member `int` @@ -518,7 +517,7 @@ PYI016.pyi:72:64: PYI016 [*] Duplicate union member `int` 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error | ^^^ PYI016 -73 | +73 | 74 | # Should emit in cases with newlines | = help: Remove duplicate union member `int` @@ -539,7 +538,7 @@ PYI016.pyi:76:12: PYI016 [*] Duplicate union member `set[int]` 75 | field23: set[ # foo 76 | int] | set[int] | ^^^^^^^^ PYI016 -77 | +77 | 78 | # Should emit twice (once for each `int` in the nested union, both of which are | = help: Remove duplicate union member `set[int]` @@ -561,7 +560,7 @@ PYI016.pyi:81:41: PYI016 [*] Duplicate union member `int` 80 | # we incorrectly re-checked the nested union). 81 | field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` | ^^^ PYI016 -82 | +82 | 83 | # Should emit twice (once for each `int` in the nested union, both of which are | = help: Remove duplicate union member `int` @@ -582,7 +581,7 @@ PYI016.pyi:81:46: PYI016 [*] Duplicate union member `int` 80 | # we incorrectly re-checked the nested union). 81 | field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` | ^^^ PYI016 -82 | +82 | 83 | # Should emit twice (once for each `int` in the nested union, both of which are | = help: Remove duplicate union member `int` @@ -603,7 +602,7 @@ PYI016.pyi:86:28: PYI016 [*] Duplicate union member `int` 85 | # we incorrectly re-checked the nested union). 86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` | ^^^ PYI016 -87 | +87 | 88 | # Should emit in cases with nested `typing.Union` | = help: Remove duplicate union member `int` @@ -624,7 +623,7 @@ PYI016.pyi:86:34: PYI016 [*] Duplicate union member `int` 85 | # we incorrectly re-checked the nested union). 86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` | ^^^ PYI016 -87 | +87 | 88 | # Should emit in cases with nested `typing.Union` | = help: Remove duplicate union member `int` @@ -644,7 +643,7 @@ PYI016.pyi:89:41: PYI016 [*] Duplicate union member `int` 88 | # Should emit in cases with nested `typing.Union` 89 | field26: typing.Union[typing.Union[int, int]] # PYI016: Duplicate union member `int` | ^^^ PYI016 -90 | +90 | 91 | # Should emit in cases with nested `typing.Union` | = help: Remove duplicate union member `int` @@ -664,7 +663,7 @@ PYI016.pyi:92:54: PYI016 [*] Duplicate union member `int` 91 | # Should emit in cases with nested `typing.Union` 92 | field27: typing.Union[typing.Union[typing.Union[int, int]]] # PYI016: Duplicate union member `int` | ^^^ PYI016 -93 | +93 | 94 | # Should emit in cases with mixed `typing.Union` and `|` | = help: Remove duplicate union member `int` @@ -684,7 +683,7 @@ PYI016.pyi:95:29: PYI016 [*] Duplicate union member `int` 94 | # Should emit in cases with mixed `typing.Union` and `|` 95 | field28: typing.Union[int | int] # Error | ^^^ PYI016 -96 | +96 | 97 | # Should emit twice in cases with multiple nested `typing.Union` | = help: Remove duplicate union member `int` @@ -704,7 +703,7 @@ PYI016.pyi:98:54: PYI016 [*] Duplicate union member `int` 97 | # Should emit twice in cases with multiple nested `typing.Union` 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error | ^^^ PYI016 - 99 | + 99 | 100 | # Should emit once in cases with multiple nested `typing.Union` | = help: Remove duplicate union member `int` @@ -724,7 +723,7 @@ PYI016.pyi:98:59: PYI016 [*] Duplicate union member `int` 97 | # Should emit twice in cases with multiple nested `typing.Union` 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error | ^^^ PYI016 - 99 | + 99 | 100 | # Should emit once in cases with multiple nested `typing.Union` | = help: Remove duplicate union member `int` @@ -744,7 +743,7 @@ PYI016.pyi:101:54: PYI016 [*] Duplicate union member `int` 100 | # Should emit once in cases with multiple nested `typing.Union` 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]] # Error | ^^^ PYI016 -102 | +102 | 103 | # Should emit once, and fix to `typing.Union[float, int]` | = help: Remove duplicate union member `int` @@ -764,7 +763,7 @@ PYI016.pyi:104:49: PYI016 [*] Duplicate union member `int` 103 | # Should emit once, and fix to `typing.Union[float, int]` 104 | field31: typing.Union[float, typing.Union[int | int]] # Error | ^^^ PYI016 -105 | +105 | 106 | # Should emit once, and fix to `typing.Union[float, int]` | = help: Remove duplicate union member `int` @@ -784,7 +783,7 @@ PYI016.pyi:107:49: PYI016 [*] Duplicate union member `int` 106 | # Should emit once, and fix to `typing.Union[float, int]` 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error | ^^^ PYI016 -108 | +108 | 109 | # Test case for mixed union type fix | = help: Remove duplicate union member `int` @@ -804,7 +803,7 @@ PYI016.pyi:107:55: PYI016 [*] Duplicate union member `int` 106 | # Should emit once, and fix to `typing.Union[float, int]` 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error | ^^^ PYI016 -108 | +108 | 109 | # Test case for mixed union type fix | = help: Remove duplicate union member `int` @@ -824,7 +823,7 @@ PYI016.pyi:110:42: PYI016 [*] Duplicate union member `int` 109 | # Test case for mixed union type fix 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error | ^^^ PYI016 -111 | +111 | 112 | # Test case for mixed union type | = help: Remove duplicate union member `int` @@ -844,7 +843,7 @@ PYI016.pyi:110:62: PYI016 [*] Duplicate union member `int` 109 | # Test case for mixed union type fix 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error | ^^^ PYI016 -111 | +111 | 112 | # Test case for mixed union type | = help: Remove duplicate union member `int` @@ -864,7 +863,7 @@ PYI016.pyi:110:68: PYI016 [*] Duplicate union member `int` 109 | # Test case for mixed union type fix 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error | ^^^ PYI016 -111 | +111 | 112 | # Test case for mixed union type | = help: Remove duplicate union member `int` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI021_PYI021.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI021_PYI021.pyi.snap index 6560778919a50..a135eb377b657 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI021_PYI021.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI021_PYI021.pyi.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI021.pyi:1:1: PYI021 [*] Docstrings should not be included in stubs | 1 | """foo""" # ERROR PYI021 | ^^^^^^^^^ PYI021 -2 | +2 | 3 | def foo(): | = help: Remove docstring @@ -23,7 +22,7 @@ PYI021.pyi:4:5: PYI021 [*] Docstrings should not be included in stubs 3 | def foo(): 4 | """foo""" # ERROR PYI021 | ^^^^^^^^^ PYI021 -5 | +5 | 6 | class Bar: | = help: Remove docstring @@ -43,7 +42,7 @@ PYI021.pyi:7:5: PYI021 [*] Docstrings should not be included in stubs 6 | class Bar: 7 | """bar""" # ERROR PYI021 | ^^^^^^^^^ PYI021 -8 | +8 | 9 | class Qux: | = help: Remove docstring @@ -63,7 +62,7 @@ PYI021.pyi:10:5: PYI021 [*] Docstrings should not be included in stubs 9 | class Qux: 10 | """qux""" # ERROR PYI021 | ^^^^^^^^^ PYI021 -11 | +11 | 12 | def __init__(self) -> None: ... | = help: Remove docstring @@ -81,13 +80,12 @@ PYI021.pyi:10:5: PYI021 [*] Docstrings should not be included in stubs PYI021.pyi:15:5: PYI021 [*] Docstrings should not be included in stubs | 14 | class Baz: -15 | """Multiline docstring - | _____^ -16 | | +15 | / """Multiline docstring +16 | | 17 | | Lorem ipsum dolor sit amet 18 | | """ | |_______^ PYI021 -19 | +19 | 20 | def __init__(self) -> None: ... | = help: Remove docstring diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041.py.snap index 59d3c7262038c..b4680e7da885a 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041.py.snap @@ -193,8 +193,7 @@ PYI041.py:67:9: PYI041 [*] Use `complex` instead of `int | float | complex` | 65 | def f10( 66 | arg: ( -67 | int | # comment - | _________^ +67 | / int | # comment 68 | | float | # another 69 | | complex | |_______________^ PYI041 @@ -216,7 +215,7 @@ PYI041.py:67:9: PYI041 [*] Use `complex` instead of `int | float | complex` PYI041.py:79:24: PYI041 [*] Use `complex` instead of `int | float | complex` | 77 | ... -78 | +78 | 79 | def bad(self, arg: int | float | complex) -> None: | ^^^^^^^^^^^^^^^^^^^^^ PYI041 80 | ... @@ -236,7 +235,7 @@ PYI041.py:79:24: PYI041 [*] Use `complex` instead of `int | float | complex` PYI041.py:82:25: PYI041 [*] Use `complex` instead of `int | float | complex` | 80 | ... -81 | +81 | 82 | def bad2(self, arg: int | Union[float, complex]) -> None: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 83 | ... @@ -256,7 +255,7 @@ PYI041.py:82:25: PYI041 [*] Use `complex` instead of `int | float | complex` PYI041.py:85:25: PYI041 [*] Use `complex` instead of `int | float | complex` | 83 | ... -84 | +84 | 85 | def bad3(self, arg: Union[Union[float, complex], int]) -> None: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 86 | ... @@ -276,7 +275,7 @@ PYI041.py:85:25: PYI041 [*] Use `complex` instead of `int | float | complex` PYI041.py:88:25: PYI041 [*] Use `complex` instead of `int | float | complex` | 86 | ... -87 | +87 | 88 | def bad4(self, arg: Union[float | complex, int]) -> None: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 89 | ... @@ -296,7 +295,7 @@ PYI041.py:88:25: PYI041 [*] Use `complex` instead of `int | float | complex` PYI041.py:91:25: PYI041 [*] Use `complex` instead of `int | float | complex` | 89 | ... -90 | +90 | 91 | def bad5(self, arg: int | (float | complex)) -> None: | ^^^^^^^^^^^^^^^^^^^^^^^ PYI041 92 | ... diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041.pyi.snap index 6f9eeda4b18a9..dbf365cb5bdc7 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041.pyi.snap @@ -74,7 +74,7 @@ PYI041.pyi:33:24: PYI041 [*] Use `float` instead of `int | float` | 33 | async def f4(**kwargs: int | int | float) -> None: ... # PYI041 | ^^^^^^^^^^^^^^^^^ PYI041 -34 | +34 | 35 | def f5( | = help: Remove redundant type @@ -117,8 +117,7 @@ PYI041.pyi:43:9: PYI041 [*] Use `complex` instead of `int | float | complex` | 41 | def f6( 42 | arg: ( -43 | int | # comment - | _________^ +43 | / int | # comment 44 | | float | # another 45 | | complex | |_______________^ PYI041 @@ -140,7 +139,7 @@ PYI041.pyi:43:9: PYI041 [*] Use `complex` instead of `int | float | complex` PYI041.pyi:49:26: PYI041 [*] Use `float` instead of `int | float` | 47 | ) -> None: ... # PYI041 -48 | +48 | 49 | def f5(arg1: int, *args: Union[int, int, float]) -> None: ... # PYI041 | ^^^^^^^^^^^^^^^^^^^^^^ PYI041 | @@ -210,10 +209,10 @@ PYI041.pyi:58:26: PYI041 [*] Use `float` instead of `int | float` PYI041.pyi:64:24: PYI041 [*] Use `complex` instead of `int | float | complex` | 62 | def good(self, arg: int) -> None: ... -63 | +63 | 64 | def bad(self, arg: int | float | complex) -> None: ... # PYI041 | ^^^^^^^^^^^^^^^^^^^^^ PYI041 -65 | +65 | 66 | def bad2(self, arg: int | Union[float, complex]) -> None: ... # PYI041 | = help: Remove redundant type @@ -231,10 +230,10 @@ PYI041.pyi:64:24: PYI041 [*] Use `complex` instead of `int | float | complex` PYI041.pyi:66:25: PYI041 [*] Use `complex` instead of `int | float | complex` | 64 | def bad(self, arg: int | float | complex) -> None: ... # PYI041 -65 | +65 | 66 | def bad2(self, arg: int | Union[float, complex]) -> None: ... # PYI041 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 -67 | +67 | 68 | def bad3(self, arg: Union[Union[float, complex], int]) -> None: ... # PYI041 | = help: Remove redundant type @@ -252,10 +251,10 @@ PYI041.pyi:66:25: PYI041 [*] Use `complex` instead of `int | float | complex` PYI041.pyi:68:25: PYI041 [*] Use `complex` instead of `int | float | complex` | 66 | def bad2(self, arg: int | Union[float, complex]) -> None: ... # PYI041 -67 | +67 | 68 | def bad3(self, arg: Union[Union[float, complex], int]) -> None: ... # PYI041 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 -69 | +69 | 70 | def bad4(self, arg: Union[float | complex, int]) -> None: ... # PYI041 | = help: Remove redundant type @@ -273,10 +272,10 @@ PYI041.pyi:68:25: PYI041 [*] Use `complex` instead of `int | float | complex` PYI041.pyi:70:25: PYI041 [*] Use `complex` instead of `int | float | complex` | 68 | def bad3(self, arg: Union[Union[float, complex], int]) -> None: ... # PYI041 -69 | +69 | 70 | def bad4(self, arg: Union[float | complex, int]) -> None: ... # PYI041 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 -71 | +71 | 72 | def bad5(self, arg: int | (float | complex)) -> None: ... # PYI041 | = help: Remove redundant type @@ -293,7 +292,7 @@ PYI041.pyi:70:25: PYI041 [*] Use `complex` instead of `int | float | complex` PYI041.pyi:72:25: PYI041 [*] Use `complex` instead of `int | float | complex` | 70 | def bad4(self, arg: Union[float | complex, int]) -> None: ... # PYI041 -71 | +71 | 72 | def bad5(self, arg: int | (float | complex)) -> None: ... # PYI041 | ^^^^^^^^^^^^^^^^^^^^^^^ PYI041 | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT003.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT003.snap index cb9365cd0fb64..f57950bcd4dd4 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT003.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT003.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- PT003.py:14:17: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` | @@ -142,8 +141,7 @@ PT003.py:66:5: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` | 64 | # another comment ,) 65 | -66 | scope=\ - | _____^ +66 | / scope=\ 67 | | "function" # some comment ), | |__________________^ PT003 68 | , diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_csv.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_csv.snap index 1351afc9218f6..1d00aa145382c 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_csv.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_csv.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- PT006.py:24:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected a string of comma-separated values | @@ -157,8 +156,7 @@ PT006.py:103:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa | 101 | # Unsafe fix 102 | @pytest.mark.parametrize( -103 | ( - | _____^ +103 | / ( 104 | | # comment 105 | | "param", 106 | | ), diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_default.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_default.snap index fa23a2d752c26..78a833a98cf15 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_default.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_default.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- PT006.py:9:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` | @@ -329,8 +328,7 @@ PT006.py:103:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa | 101 | # Unsafe fix 102 | @pytest.mark.parametrize( -103 | ( - | _____^ +103 | / ( 104 | | # comment 105 | | "param", 106 | | ), diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_list.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_list.snap index 8ccc8345e7b99..affd3540c95e2 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_list.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_list.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- PT006.py:9:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `list` | @@ -291,8 +290,7 @@ PT006.py:103:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa | 101 | # Unsafe fix 102 | @pytest.mark.parametrize( -103 | ( - | _____^ +103 | / ( 104 | | # comment 105 | | "param", 106 | | ), diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_lists.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_lists.snap index 16b6d8e5b7cbb..f3b1a2bb66efb 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_lists.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_lists.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- PT007.py:4:35: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `list` | @@ -25,8 +24,7 @@ PT007.py:11:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected | 9 | @pytest.mark.parametrize( 10 | ("param1", "param2"), -11 | ( - | _____^ +11 | / ( 12 | | (1, 2), 13 | | (3, 4), 14 | | ), @@ -96,8 +94,7 @@ PT007.py:22:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected | 20 | @pytest.mark.parametrize( 21 | ("param1", "param2"), -22 | ( - | _____^ +22 | / ( 23 | | [1, 2], 24 | | [3, 4], 25 | | ), diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_tuples.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_tuples.snap index 17d3ebe463138..c3bb7dde901b2 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_tuples.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_tuples.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- PT007.py:4:35: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` | @@ -25,8 +24,7 @@ PT007.py:11:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected | 9 | @pytest.mark.parametrize( 10 | ("param1", "param2"), -11 | ( - | _____^ +11 | / ( 12 | | (1, 2), 13 | | (3, 4), 14 | | ), @@ -54,8 +52,7 @@ PT007.py:22:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected | 20 | @pytest.mark.parametrize( 21 | ("param1", "param2"), -22 | ( - | _____^ +22 | / ( 23 | | [1, 2], 24 | | [3, 4], 25 | | ), diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_lists.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_lists.snap index 2d2089f04bf5e..48e4d90b11a78 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_lists.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_lists.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- PT007.py:12:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` | @@ -67,8 +66,7 @@ PT007.py:38:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected | 36 | @pytest.mark.parametrize( 37 | ("param1", "param2"), -38 | [ - | _____^ +38 | / [ 39 | | (1, 2), 40 | | (3, 4), 41 | | ], @@ -138,8 +136,7 @@ PT007.py:49:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected | 47 | @pytest.mark.parametrize( 48 | ("param1", "param2"), -49 | [ - | _____^ +49 | / [ 50 | | [1, 2], 51 | | [3, 4], 52 | | ], @@ -167,8 +164,7 @@ PT007.py:60:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected | 58 | @pytest.mark.parametrize( 59 | "param1,param2", -60 | [ - | _____^ +60 | / [ 61 | | [1, 2], 62 | | [3, 4], 63 | | ], @@ -196,8 +192,7 @@ PT007.py:71:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected | 69 | @pytest.mark.parametrize( 70 | "param", -71 | [ - | _____^ +71 | / [ 72 | | [1, 2], 73 | | [3, 4], 74 | | ], diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_tuples.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_tuples.snap index 00e160ebdad5f..822c8869ec4ac 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_tuples.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_tuples.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- PT007.py:23:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` | @@ -67,8 +66,7 @@ PT007.py:38:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected | 36 | @pytest.mark.parametrize( 37 | ("param1", "param2"), -38 | [ - | _____^ +38 | / [ 39 | | (1, 2), 40 | | (3, 4), 41 | | ], @@ -96,8 +94,7 @@ PT007.py:49:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected | 47 | @pytest.mark.parametrize( 48 | ("param1", "param2"), -49 | [ - | _____^ +49 | / [ 50 | | [1, 2], 51 | | [3, 4], 52 | | ], @@ -167,8 +164,7 @@ PT007.py:60:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected | 58 | @pytest.mark.parametrize( 59 | "param1,param2", -60 | [ - | _____^ +60 | / [ 61 | | [1, 2], 62 | | [3, 4], 63 | | ], @@ -238,8 +234,7 @@ PT007.py:71:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected | 69 | @pytest.mark.parametrize( 70 | "param", -71 | [ - | _____^ +71 | / [ 72 | | [1, 2], 73 | | [3, 4], 74 | | ], diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT012.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT012.snap index 469faa3fb061c..0bfc3ee2ce5c5 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT012.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT012.snap @@ -1,12 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- PT012.py:42:5: PT012 `pytest.raises()` block should contain a single simple statement | 41 | def test_error_multiple_statements(): -42 | with pytest.raises(AttributeError): - | _____^ +42 | / with pytest.raises(AttributeError): 43 | | len([]) 44 | | [].size | |_______________^ PT012 @@ -15,60 +13,55 @@ PT012.py:42:5: PT012 `pytest.raises()` block should contain a single simple stat PT012.py:48:5: PT012 `pytest.raises()` block should contain a single simple statement | 47 | async def test_error_complex_statement(): -48 | with pytest.raises(AttributeError): - | _____^ +48 | / with pytest.raises(AttributeError): 49 | | if True: 50 | | [].size | |___________________^ PT012 -51 | +51 | 52 | with pytest.raises(AttributeError): | PT012.py:52:5: PT012 `pytest.raises()` block should contain a single simple statement | 50 | [].size -51 | -52 | with pytest.raises(AttributeError): - | _____^ +51 | +52 | / with pytest.raises(AttributeError): 53 | | for i in []: 54 | | [].size | |___________________^ PT012 -55 | +55 | 56 | with pytest.raises(AttributeError): | PT012.py:56:5: PT012 `pytest.raises()` block should contain a single simple statement | 54 | [].size -55 | -56 | with pytest.raises(AttributeError): - | _____^ +55 | +56 | / with pytest.raises(AttributeError): 57 | | async for i in []: 58 | | [].size | |___________________^ PT012 -59 | +59 | 60 | with pytest.raises(AttributeError): | PT012.py:60:5: PT012 `pytest.raises()` block should contain a single simple statement | 58 | [].size -59 | -60 | with pytest.raises(AttributeError): - | _____^ +59 | +60 | / with pytest.raises(AttributeError): 61 | | while True: 62 | | [].size | |___________________^ PT012 -63 | +63 | 64 | with pytest.raises(AttributeError): | PT012.py:64:5: PT012 `pytest.raises()` block should contain a single simple statement | 62 | [].size -63 | -64 | with pytest.raises(AttributeError): - | _____^ +63 | +64 | / with pytest.raises(AttributeError): 65 | | async with context_manager_under_test(): 66 | | if True: 67 | | raise Exception @@ -78,8 +71,7 @@ PT012.py:64:5: PT012 `pytest.raises()` block should contain a single simple stat PT012.py:71:5: PT012 `pytest.raises()` block should contain a single simple statement | 70 | def test_error_try(): -71 | with pytest.raises(AttributeError): - | _____^ +71 | / with pytest.raises(AttributeError): 72 | | try: 73 | | [].size 74 | | except: diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT018.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT018.snap index 4d6b8eb0653bc..15ef642752227 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT018.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT018.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- PT018.py:14:5: PT018 [*] Assertion should be broken down into multiple parts | @@ -159,8 +158,7 @@ PT018.py:21:5: PT018 [*] Assertion should be broken down into multiple parts | 19 | assert not (something or something_else) 20 | assert not (something or something_else or something_third) -21 | assert something and something_else == """error - | _____^ +21 | / assert something and something_else == """error 22 | | message 23 | | """ | |_______^ PT018 @@ -184,8 +182,7 @@ PT018.py:24:5: PT018 [*] Assertion should be broken down into multiple parts | 22 | message 23 | """ -24 | assert ( - | _____^ +24 | / assert ( 25 | | something 26 | | and something_else 27 | | == """error @@ -193,7 +190,7 @@ PT018.py:24:5: PT018 [*] Assertion should be broken down into multiple parts 29 | | """ 30 | | ) | |_____^ PT018 -31 | +31 | 32 | # recursive case | = help: Break down assertion into multiple parts @@ -237,7 +234,7 @@ PT018.py:34:5: PT018 [*] Assertion should be broken down into multiple parts 33 | assert not (a or not (b or c)) 34 | assert not (a or not (b and c)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 -35 | +35 | 36 | # detected, but no fix for messages | = help: Break down assertion into multiple parts @@ -328,7 +325,7 @@ PT018.py:49:5: PT018 Assertion should be broken down into multiple parts 48 | def test_multiline(): 49 | assert something and something_else; x = 1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 -50 | +50 | 51 | x = 1; assert something and something_else | = help: Break down assertion into multiple parts @@ -336,10 +333,10 @@ PT018.py:49:5: PT018 Assertion should be broken down into multiple parts PT018.py:51:12: PT018 Assertion should be broken down into multiple parts | 49 | assert something and something_else; x = 1 -50 | +50 | 51 | x = 1; assert something and something_else | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 -52 | +52 | 53 | x = 1; \ | = help: Break down assertion into multiple parts @@ -356,14 +353,13 @@ PT018.py:59:5: PT018 [*] Assertion should be broken down into multiple parts | 57 | # Regression test for: https://github.com/astral-sh/ruff/issues/7143 58 | def test_parenthesized_not(): -59 | assert not ( - | _____^ +59 | / assert not ( 60 | | self.find_graph_output(node.output[0]) 61 | | or self.find_graph_input(node.input[0]) 62 | | or self.find_graph_output(node.input[0]) 63 | | ) | |_____^ PT018 -64 | +64 | 65 | assert (not ( | = help: Break down assertion into multiple parts @@ -384,15 +380,14 @@ PT018.py:59:5: PT018 [*] Assertion should be broken down into multiple parts PT018.py:65:5: PT018 [*] Assertion should be broken down into multiple parts | 63 | ) -64 | -65 | assert (not ( - | _____^ +64 | +65 | / assert (not ( 66 | | self.find_graph_output(node.output[0]) 67 | | or self.find_graph_input(node.input[0]) 68 | | or self.find_graph_output(node.input[0]) 69 | | )) | |______^ PT018 -70 | +70 | 71 | assert (not self.find_graph_output(node.output[0]) or | = help: Break down assertion into multiple parts diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_0.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_0.snap index 344bb2b4ca830..33e15bb5b08e1 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_0.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_0.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- PT027_0.py:6:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` | @@ -54,7 +53,7 @@ PT027_0.py:8:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assert PT027_0.py:11:14: PT027 [*] Use `pytest.raises` instead of unittest-style `failUnlessRaises` | 9 | raise ValueError -10 | +10 | 11 | with self.failUnlessRaises(ValueError): | ^^^^^^^^^^^^^^^^^^^^^ PT027 12 | raise ValueError @@ -80,7 +79,7 @@ PT027_0.py:11:14: PT027 [*] Use `pytest.raises` instead of unittest-style `failU PT027_0.py:14:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` | 12 | raise ValueError -13 | +13 | 14 | with self.assertRaisesRegex(ValueError, "test"): | ^^^^^^^^^^^^^^^^^^^^^^ PT027 15 | raise ValueError("test") @@ -106,7 +105,7 @@ PT027_0.py:14:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser PT027_0.py:17:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` | 15 | raise ValueError("test") -16 | +16 | 17 | with self.assertRaisesRegex(ValueError, expected_regex="test"): | ^^^^^^^^^^^^^^^^^^^^^^ PT027 18 | raise ValueError("test") @@ -132,7 +131,7 @@ PT027_0.py:17:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser PT027_0.py:20:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` | 18 | raise ValueError("test") -19 | +19 | 20 | with self.assertRaisesRegex( | ^^^^^^^^^^^^^^^^^^^^^^ PT027 21 | expected_exception=ValueError, expected_regex="test" @@ -161,7 +160,7 @@ PT027_0.py:20:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser PT027_0.py:25:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` | 23 | raise ValueError("test") -24 | +24 | 25 | with self.assertRaisesRegex( | ^^^^^^^^^^^^^^^^^^^^^^ PT027 26 | expected_regex="test", expected_exception=ValueError @@ -190,7 +189,7 @@ PT027_0.py:25:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser PT027_0.py:30:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegexp` | 28 | raise ValueError("test") -29 | +29 | 30 | with self.assertRaisesRegexp(ValueError, "test"): | ^^^^^^^^^^^^^^^^^^^^^^^ PT027 31 | raise ValueError("test") @@ -225,7 +224,7 @@ PT027_0.py:34:14: PT027 Use `pytest.raises` instead of unittest-style `assertRai PT027_0.py:37:14: PT027 Use `pytest.raises` instead of unittest-style `assertRaises` | 35 | raise ValueError -36 | +36 | 37 | with self.assertRaises( | ^^^^^^^^^^^^^^^^^ PT027 38 | # comment @@ -236,8 +235,7 @@ PT027_0.py:37:14: PT027 Use `pytest.raises` instead of unittest-style `assertRai PT027_0.py:44:13: PT027 Use `pytest.raises` instead of unittest-style `assertRaises` | 43 | with ( -44 | self - | _____________^ +44 | / self 45 | | # comment 46 | | .assertRaises(ValueError) | |_________________________^ PT027 diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles.py.snap index da092eac7ee25..4f3a569bdedb2 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles.py.snap @@ -1,16 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- docstring_doubles.py:5:1: Q001 [*] Double quote multiline found but single quotes preferred | 3 | """ -4 | +4 | 5 | / """ 6 | | this is not a docstring 7 | | """ | |___^ Q001 -8 | +8 | 9 | l = [] | = help: Replace double multiline quotes with single quotes @@ -31,13 +30,12 @@ docstring_doubles.py:5:1: Q001 [*] Double quote multiline found but single quote docstring_doubles.py:16:5: Q001 [*] Double quote multiline found but single quotes preferred | 14 | """ -15 | -16 | """ - | _____^ +15 | +16 | / """ 17 | | this is not a docstring 18 | | """ | |_______^ Q001 -19 | +19 | 20 | # The colon in the list indexing below is an edge case for the docstring scanner | = help: Replace double multiline quotes with single quotes @@ -82,13 +80,12 @@ docstring_doubles.py:21:21: Q001 [*] Double quote multiline found but single quo docstring_doubles.py:30:9: Q001 [*] Double quote multiline found but single quotes preferred | 28 | some_expression = 'hello world' -29 | -30 | """ - | _________^ +29 | +30 | / """ 31 | | this is not a docstring 32 | | """ | |___________^ Q001 -33 | +33 | 34 | if l: | = help: Replace double multiline quotes with single quotes @@ -109,8 +106,7 @@ docstring_doubles.py:30:9: Q001 [*] Double quote multiline found but single quot docstring_doubles.py:35:13: Q001 [*] Double quote multiline found but single quotes preferred | 34 | if l: -35 | """ - | _____________^ +35 | / """ 36 | | Looks like a docstring, but in reality it isn't - only modules, classes and functions 37 | | """ | |_______________^ Q001 diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles.py.snap index cd7790e71b755..c73763820c4f3 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- docstring_singles.py:1:1: Q002 [*] Single quote docstring found but double quotes preferred | @@ -8,7 +7,7 @@ docstring_singles.py:1:1: Q002 [*] Single quote docstring found but double quote 2 | | Single quotes multiline module docstring 3 | | ''' | |___^ Q002 -4 | +4 | 5 | ''' | = help: Replace single quotes docstring with double quotes @@ -27,12 +26,11 @@ docstring_singles.py:14:5: Q002 [*] Single quote docstring found but double quot | 12 | class params \t not a docstring 13 | ''')): -14 | ''' - | _____^ +14 | / ''' 15 | | Single quotes multiline class docstring 16 | | ''' | |_______^ Q002 -17 | +17 | 18 | ''' | = help: Replace single quotes docstring with double quotes @@ -54,12 +52,11 @@ docstring_singles.py:26:9: Q002 [*] Single quote docstring found but double quot | 24 | definitely not a docstring''', 25 | val=l[Cls():3]): -26 | ''' - | _________^ +26 | / ''' 27 | | Single quotes multiline function docstring 28 | | ''' | |___________^ Q002 -29 | +29 | 30 | some_expression = 'hello world' | = help: Replace single quotes docstring with double quotes diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_function.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_function.py.snap index 6f6088b6912ae..5c0f5b436b45a 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_function.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_function.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- docstring_singles_function.py:2:5: Q002 [*] Single quote docstring found but double quotes preferred | @@ -23,8 +22,7 @@ docstring_singles_function.py:2:5: Q002 [*] Single quote docstring found but dou docstring_singles_function.py:8:5: Q002 [*] Single quote docstring found but double quotes preferred | 7 | def foo2(): - 8 | ''' - | _____^ + 8 | / ''' 9 | | function without params, multiline docstring 10 | | ''' | |_______^ Q002 diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles.py.snap index 28116f3c491db..84c7afaab8abd 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- docstring_doubles.py:1:1: Q002 [*] Double quote docstring found but single quotes preferred | @@ -8,7 +7,7 @@ docstring_doubles.py:1:1: Q002 [*] Double quote docstring found but single quote 2 | | Double quotes multiline module docstring 3 | | """ | |___^ Q002 -4 | +4 | 5 | """ | = help: Replace double quotes docstring with single quotes @@ -26,12 +25,11 @@ docstring_doubles.py:1:1: Q002 [*] Double quote docstring found but single quote docstring_doubles.py:12:5: Q002 [*] Double quote docstring found but single quotes preferred | 11 | class Cls: -12 | """ - | _____^ +12 | / """ 13 | | Double quotes multiline class docstring 14 | | """ | |_______^ Q002 -15 | +15 | 16 | """ | = help: Replace double quotes docstring with single quotes @@ -53,12 +51,11 @@ docstring_doubles.py:24:9: Q002 [*] Double quote docstring found but single quot | 22 | definitely not a docstring""", 23 | val=l[Cls():3]): -24 | """ - | _________^ +24 | / """ 25 | | Double quotes multiline function docstring 26 | | """ | |___________^ Q002 -27 | +27 | 28 | some_expression = 'hello world' | = help: Replace double quotes docstring with single quotes diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_function.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_function.py.snap index 4d3427a7abb05..e33863957c4b6 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_function.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_function.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- docstring_doubles_function.py:2:5: Q002 [*] Double quote docstring found but single quotes preferred | @@ -23,8 +22,7 @@ docstring_doubles_function.py:2:5: Q002 [*] Double quote docstring found but sin docstring_doubles_function.py:8:5: Q002 [*] Double quote docstring found but single quotes preferred | 7 | def foo2(): - 8 | """ - | _____^ + 8 | / """ 9 | | function without params, multiline docstring 10 | | """ | |_______^ Q002 diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles.py.snap index d3fb063bfcb21..43c7b6b7f8a7b 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles.py.snap @@ -1,16 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- docstring_singles.py:5:1: Q001 [*] Single quote multiline found but double quotes preferred | 3 | ''' -4 | +4 | 5 | / ''' 6 | | this is not a docstring 7 | | ''' | |___^ Q001 -8 | +8 | 9 | l = [] | = help: Replace single multiline quotes with double quotes @@ -31,7 +30,7 @@ docstring_singles.py:5:1: Q001 [*] Single quote multiline found but double quote docstring_singles.py:11:21: Q001 [*] Single quote multiline found but double quotes preferred | 9 | l = [] -10 | +10 | 11 | class Cls(MakeKlass(''' | _____________________^ 12 | | class params \t not a docstring @@ -58,13 +57,12 @@ docstring_singles.py:11:21: Q001 [*] Single quote multiline found but double quo docstring_singles.py:18:5: Q001 [*] Single quote multiline found but double quotes preferred | 16 | ''' -17 | -18 | ''' - | _____^ +17 | +18 | / ''' 19 | | this is not a docstring 20 | | ''' | |_______^ Q001 -21 | +21 | 22 | # The colon in the list indexing below is an edge case for the docstring scanner | = help: Replace single multiline quotes with double quotes @@ -109,13 +107,12 @@ docstring_singles.py:23:21: Q001 [*] Single quote multiline found but double quo docstring_singles.py:32:9: Q001 [*] Single quote multiline found but double quotes preferred | 30 | some_expression = 'hello world' -31 | -32 | ''' - | _________^ +31 | +32 | / ''' 33 | | this is not a docstring 34 | | ''' | |___________^ Q001 -35 | +35 | 36 | if l: | = help: Replace single multiline quotes with double quotes @@ -136,8 +133,7 @@ docstring_singles.py:32:9: Q001 [*] Single quote multiline found but double quot docstring_singles.py:37:13: Q001 [*] Single quote multiline found but double quotes preferred | 36 | if l: -37 | ''' - | _____________^ +37 | / ''' 38 | | Looks like a docstring, but in reality it isn't - only modules, classes and functions 39 | | ''' | |_______________^ Q001 diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET503_RET503.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET503_RET503.py.snap index c3dca0659c4f4..af2cbb50470d3 100644 --- a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET503_RET503.py.snap +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET503_RET503.py.snap @@ -1,13 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_return/mod.rs -snapshot_kind: text --- RET503.py:21:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | 19 | # if/elif/else 20 | def x(y): -21 | if not y: - | _____^ +21 | / if not y: 22 | | return 1 | |________________^ RET503 23 | # error @@ -46,7 +44,7 @@ RET503.py:28:9: RET503 [*] Missing explicit `return` at the end of function able RET503.py:37:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | 35 | return 1 -36 | +36 | 37 | print() # error | ^^^^^^^ RET503 | @@ -65,8 +63,7 @@ RET503.py:42:5: RET503 [*] Missing explicit `return` at the end of function able | 40 | # for 41 | def x(y): -42 | for i in range(10): - | _____^ +42 | / for i in range(10): 43 | | if i > 10: 44 | | return i | |____________________^ RET503 @@ -141,8 +138,7 @@ RET503.py:83:5: RET503 [*] Missing explicit `return` at the end of function able | 81 | # last line in while loop 82 | def x(y): -83 | while i > 0: - | _____^ +83 | / while i > 0: 84 | | if y > 0: 85 | | return 1 86 | | y += 1 @@ -163,8 +159,7 @@ RET503.py:114:5: RET503 [*] Missing explicit `return` at the end of function abl | 112 | # return value within loop 113 | def bar1(x, y, z): -114 | for i in x: - | _____^ +114 | / for i in x: 115 | | if i > y: 116 | | break 117 | | return z @@ -184,8 +179,7 @@ RET503.py:114:5: RET503 [*] Missing explicit `return` at the end of function abl RET503.py:121:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | 120 | def bar3(x, y, z): -121 | for i in x: - | _____^ +121 | / for i in x: 122 | | if i > y: 123 | | if z: 124 | | break @@ -208,8 +202,7 @@ RET503.py:121:5: RET503 [*] Missing explicit `return` at the end of function abl RET503.py:131:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | 130 | def bar1(x, y, z): -131 | for i in x: - | _____^ +131 | / for i in x: 132 | | if i < y: 133 | | continue 134 | | return z @@ -229,8 +222,7 @@ RET503.py:131:5: RET503 [*] Missing explicit `return` at the end of function abl RET503.py:138:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | 137 | def bar3(x, y, z): -138 | for i in x: - | _____^ +138 | / for i in x: 139 | | if i < y: 140 | | if z: 141 | | continue @@ -253,9 +245,8 @@ RET503.py:138:5: RET503 [*] Missing explicit `return` at the end of function abl RET503.py:275:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | 273 | return False -274 | -275 | for value in values: - | _____^ +274 | +275 | / for value in values: 276 | | print(value) | |____________________^ RET503 | @@ -292,8 +283,7 @@ RET503.py:301:9: RET503 [*] Missing explicit `return` at the end of function abl | 299 | def end_of_statement(): 300 | def example(): -301 | if True: - | _________^ +301 | / if True: 302 | | return "" | |_____________________^ RET503 | @@ -311,8 +301,7 @@ RET503.py:301:9: RET503 [*] Missing explicit `return` at the end of function abl RET503.py:306:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | 305 | def example(): -306 | if True: - | _________^ +306 | / if True: 307 | | return "" | |_____________________^ RET503 | @@ -330,8 +319,7 @@ RET503.py:306:9: RET503 [*] Missing explicit `return` at the end of function abl RET503.py:311:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | 310 | def example(): -311 | if True: - | _________^ +311 | / if True: 312 | | return "" # type: ignore | |_____________________^ RET503 | @@ -349,8 +337,7 @@ RET503.py:311:9: RET503 [*] Missing explicit `return` at the end of function abl RET503.py:316:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | 315 | def example(): -316 | if True: - | _________^ +316 | / if True: 317 | | return "" ; | |_____________________^ RET503 | @@ -368,8 +355,7 @@ RET503.py:316:9: RET503 [*] Missing explicit `return` at the end of function abl RET503.py:321:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | 320 | def example(): -321 | if True: - | _________^ +321 | / if True: 322 | | return "" \ | |_____________________^ RET503 323 | ; # type: ignore diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__preview__RET503_RET503.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__preview__RET503_RET503.py.snap index 2964928c806bc..91c961e50974d 100644 --- a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__preview__RET503_RET503.py.snap +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__preview__RET503_RET503.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_return/mod.rs -snapshot_kind: text --- RET503.py:20:1: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -47,7 +46,7 @@ RET503.py:33:1: RET503 [*] Missing explicit `return` at the end of function able 33 | / def x(y): 34 | | if not y: 35 | | return 1 -36 | | +36 | | 37 | | print() # error | |___________^ RET503 | @@ -257,7 +256,7 @@ RET503.py:271:1: RET503 [*] Missing explicit `return` at the end of function abl 271 | / def nested(values): 272 | | if not values: 273 | | return False -274 | | +274 | | 275 | | for value in values: 276 | | print(value) | |____________________^ RET503 @@ -298,8 +297,7 @@ RET503.py:287:1: RET503 [*] Missing explicit `return` at the end of function abl RET503.py:300:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | 299 | def end_of_statement(): -300 | def example(): - | _____^ +300 | / def example(): 301 | | if True: 302 | | return "" | |_____________________^ RET503 @@ -317,8 +315,7 @@ RET503.py:300:5: RET503 [*] Missing explicit `return` at the end of function abl RET503.py:305:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | -305 | def example(): - | _____^ +305 | / def example(): 306 | | if True: 307 | | return "" | |_____________________^ RET503 @@ -336,8 +333,7 @@ RET503.py:305:5: RET503 [*] Missing explicit `return` at the end of function abl RET503.py:310:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | -310 | def example(): - | _____^ +310 | / def example(): 311 | | if True: 312 | | return "" # type: ignore | |_____________________^ RET503 @@ -355,8 +351,7 @@ RET503.py:310:5: RET503 [*] Missing explicit `return` at the end of function abl RET503.py:315:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | -315 | def example(): - | _____^ +315 | / def example(): 316 | | if True: 317 | | return "" ; | |_____________________^ RET503 @@ -374,8 +369,7 @@ RET503.py:315:5: RET503 [*] Missing explicit `return` at the end of function abl RET503.py:320:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | -320 | def example(): - | _____^ +320 | / def example(): 321 | | if True: 322 | | return "" \ | |_____________________^ RET503 diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM102_SIM102.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM102_SIM102.py.snap index 9392ee7b92fc0..6d7178e3616f4 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM102_SIM102.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM102_SIM102.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM102.py:2:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements | @@ -53,8 +52,7 @@ SIM102.py:8:5: SIM102 [*] Use a single `if` statement instead of nested `if` sta | 6 | # SIM102 7 | if a: - 8 | if b: - | _____^ + 8 | / if b: 9 | | if c: | |_____________^ SIM102 10 | d @@ -139,8 +137,7 @@ SIM102.py:51:5: SIM102 [*] Use a single `if` statement instead of nested `if` st | 49 | while x > 0: 50 | # SIM102 -51 | if y > 0: - | _____^ +51 | / if y > 0: 52 | | if z > 0: | |_________________^ SIM102 53 | """this @@ -213,8 +210,7 @@ SIM102.py:83:5: SIM102 [*] Use a single `if` statement instead of nested `if` st | 81 | while x > 0: 82 | # SIM102 -83 | if node.module: - | _____^ +83 | / if node.module: 84 | | if node.module == "multiprocessing" or node.module.startswith( 85 | | "multiprocessing." 86 | | ): @@ -285,8 +281,7 @@ SIM102.py:106:5: SIM102 [*] Use a single `if` statement instead of nested `if` s | 104 | # Regression test for https://github.com/apache/airflow/blob/145b16caaa43f0c42bffd97344df916c602cddde/airflow/configuration.py#L1161 105 | if a: -106 | if b: - | _____^ +106 | / if b: 107 | | if c: | |_____________^ SIM102 108 | print("if") @@ -311,8 +306,7 @@ SIM102.py:132:5: SIM102 [*] Use a single `if` statement instead of nested `if` s | 130 | if a: 131 | # SIM 102 -132 | if b: - | _____^ +132 | / if b: 133 | | if c: | |_____________^ SIM102 134 | print("foo") @@ -337,8 +331,7 @@ SIM102.py:165:5: SIM102 [*] Use a single `if` statement instead of nested `if` s | 163 | if a: 164 | pass -165 | elif b: - | _____^ +165 | / elif b: 166 | | if c: | |_____________^ SIM102 167 | d diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM103_SIM103.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM103_SIM103.py.snap index c8b5d7fe55944..bb3c4d87a650f 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM103_SIM103.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM103_SIM103.py.snap @@ -1,13 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM103.py:3:5: SIM103 [*] Return the condition `bool(a)` directly | 1 | def f(): 2 | # SIM103 -3 | if a: - | _____^ +3 | / if a: 4 | | return True 5 | | else: 6 | | return False @@ -31,8 +29,7 @@ SIM103.py:11:5: SIM103 [*] Return the condition `a == b` directly | 9 | def f(): 10 | # SIM103 -11 | if a == b: - | _____^ +11 | / if a == b: 12 | | return True 13 | | else: 14 | | return False @@ -57,8 +54,7 @@ SIM103.py:21:5: SIM103 [*] Return the condition `bool(b)` directly | 19 | if a: 20 | return 1 -21 | elif b: - | _____^ +21 | / elif b: 22 | | return True 23 | | else: 24 | | return False @@ -83,8 +79,7 @@ SIM103.py:32:9: SIM103 [*] Return the condition `bool(b)` directly | 30 | return 1 31 | else: -32 | if b: - | _________^ +32 | / if b: 33 | | return True 34 | | else: 35 | | return False @@ -109,8 +104,7 @@ SIM103.py:57:5: SIM103 [*] Return the condition `not a` directly | 55 | def f(): 56 | # SIM103 -57 | if a: - | _____^ +57 | / if a: 58 | | return False 59 | | else: 60 | | return True @@ -135,8 +129,7 @@ SIM103.py:83:5: SIM103 Return the condition directly | 81 | def bool(): 82 | return False -83 | if a: - | _____^ +83 | / if a: 84 | | return True 85 | | else: 86 | | return False @@ -148,8 +141,7 @@ SIM103.py:91:5: SIM103 [*] Return the condition `not (keys is not None and notic | 89 | def f(): 90 | # SIM103 -91 | if keys is not None and notice.key not in keys: - | _____^ +91 | / if keys is not None and notice.key not in keys: 92 | | return False 93 | | else: 94 | | return True @@ -174,8 +166,7 @@ SIM103.py:104:5: SIM103 [*] Return the condition `bool(a)` directly | 102 | def f(): 103 | # SIM103 -104 | if a: - | _____^ +104 | / if a: 105 | | return True 106 | | return False | |________________^ SIM103 @@ -198,8 +189,7 @@ SIM103.py:111:5: SIM103 [*] Return the condition `not a` directly | 109 | def f(): 110 | # SIM103 -111 | if a: - | _____^ +111 | / if a: 112 | | return False 113 | | return True | |_______________^ SIM103 @@ -221,8 +211,7 @@ SIM103.py:111:5: SIM103 [*] Return the condition `not a` directly SIM103.py:117:5: SIM103 [*] Return the condition `10 < a` directly | 116 | def f(): -117 | if not 10 < a: - | _____^ +117 | / if not 10 < a: 118 | | return False 119 | | return True | |_______________^ SIM103 @@ -244,8 +233,7 @@ SIM103.py:117:5: SIM103 [*] Return the condition `10 < a` directly SIM103.py:123:5: SIM103 [*] Return the condition `not 10 < a` directly | 122 | def f(): -123 | if 10 < a: - | _____^ +123 | / if 10 < a: 124 | | return False 125 | | return True | |_______________^ SIM103 diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_0.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_0.py.snap index 2b875df8c0aa9..da95917f8a763 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_0.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_0.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM105_0.py:6:1: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` | @@ -37,7 +36,7 @@ SIM105_0.py:13:1: SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` inst 15 | | except (ValueError, OSError): 16 | | pass | |________^ SIM105 -17 | +17 | 18 | # SIM105 | = help: Replace with `contextlib.suppress(ValueError, OSError)` @@ -68,7 +67,7 @@ SIM105_0.py:19:1: SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` inst 21 | | except (ValueError, OSError) as e: 22 | | pass | |________^ SIM105 -23 | +23 | 24 | # SIM105 | = help: Replace with `contextlib.suppress(ValueError, OSError)` @@ -99,7 +98,7 @@ SIM105_0.py:25:1: SIM105 [*] Use `contextlib.suppress(Exception)` instead of `tr 27 | | except: 28 | | pass | |________^ SIM105 -29 | +29 | 30 | # SIM105 | = help: Replace with `contextlib.suppress(Exception)` @@ -130,7 +129,7 @@ SIM105_0.py:31:1: SIM105 [*] Use `contextlib.suppress(a.Error, b.Error)` instead 33 | | except (a.Error, b.Error): 34 | | pass | |________^ SIM105 -35 | +35 | 36 | # OK | = help: Replace with `contextlib.suppress(a.Error, b.Error)` @@ -157,8 +156,7 @@ SIM105_0.py:85:5: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `t | 83 | def with_ellipsis(): 84 | # OK -85 | try: - | _____^ +85 | / try: 86 | | foo() 87 | | except ValueError: 88 | | ... @@ -187,13 +185,12 @@ SIM105_0.py:85:5: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `t SIM105_0.py:100:5: SIM105 Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` | 99 | def with_comment(): -100 | try: - | _____^ +100 | / try: 101 | | foo() 102 | | except (ValueError, OSError): 103 | | pass # Trailing comment. | |____________^ SIM105 -104 | +104 | 105 | try: | = help: Replace with `contextlib.suppress(ValueError, OSError)` @@ -202,13 +199,12 @@ SIM105_0.py:117:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try | 115 | # Regression test for: https://github.com/astral-sh/ruff/issues/7123 116 | def write_models(directory, Models): -117 | try: - | _____^ +117 | / try: 118 | | os.makedirs(model_dir); 119 | | except OSError: 120 | | pass; | |____________^ SIM105 -121 | +121 | 122 | try: os.makedirs(model_dir); | = help: Replace with `contextlib.suppress(OSError)` @@ -234,13 +230,12 @@ SIM105_0.py:117:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try SIM105_0.py:122:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass` | 120 | pass; -121 | -122 | try: os.makedirs(model_dir); - | _____^ +121 | +122 | / try: os.makedirs(model_dir); 123 | | except OSError: 124 | | pass; | |____________^ SIM105 -125 | +125 | 126 | try: os.makedirs(model_dir); | = help: Replace with `contextlib.suppress(OSError)` @@ -265,9 +260,8 @@ SIM105_0.py:122:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try SIM105_0.py:126:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass` | 124 | pass; -125 | -126 | try: os.makedirs(model_dir); - | _____^ +125 | +126 | / try: os.makedirs(model_dir); 127 | | except OSError: 128 | | pass; \ | |____________^ SIM105 diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_3.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_3.py.snap index 5432c2ba22dcd..22cc4a2c59c6b 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_3.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_3.py.snap @@ -1,13 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM105_3.py:10:5: SIM105 Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` | 8 | def bar(): 9 | # SIM105 -10 | try: - | _____^ +10 | / try: 11 | | foo() 12 | | except ValueError: 13 | | pass diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM108_SIM108.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM108_SIM108.py.snap index 044ff2d9c3929..de1dcf780b6da 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM108_SIM108.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM108_SIM108.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM108.py:2:1: SIM108 [*] Use ternary operator `b = c if a else d` instead of `if`-`else`-block | @@ -10,7 +9,7 @@ SIM108.py:2:1: SIM108 [*] Use ternary operator `b = c if a else d` instead of `i 4 | | else: 5 | | b = d | |_________^ SIM108 -6 | +6 | 7 | # OK | = help: Replace `if`-`else`-block with `b = c if a else d` @@ -30,8 +29,7 @@ SIM108.py:30:5: SIM108 [*] Use ternary operator `b = 1 if a else 2` instead of ` | 28 | pass 29 | else: -30 | if a: - | _____^ +30 | / if a: 31 | | b = 1 32 | | else: 33 | | b = 2 @@ -129,7 +127,7 @@ SIM108.py:141:1: SIM108 [*] Use ternary operator `z = cond if cond else other_co 143 | | else: 144 | | z = other_cond | |__________________^ SIM108 -145 | +145 | 146 | # SIM108 - should suggest | = help: Replace `if`-`else`-block with `z = cond if cond else other_cond` @@ -156,7 +154,7 @@ SIM108.py:148:1: SIM108 [*] Use ternary operator `z = cond if not cond else othe 150 | | else: 151 | | z = other_cond | |__________________^ SIM108 -152 | +152 | 153 | # SIM108 - should suggest | = help: Replace `if`-`else`-block with `z = cond if not cond else other_cond` @@ -183,7 +181,7 @@ SIM108.py:155:1: SIM108 [*] Use ternary operator `z = not cond if cond else othe 157 | | else: 158 | | z = other_cond | |__________________^ SIM108 -159 | +159 | 160 | # SIM108 does not suggest | = help: Replace `if`-`else`-block with `z = not cond if cond else other_cond` @@ -210,7 +208,7 @@ SIM108.py:167:1: SIM108 [*] Use ternary operator `z = 1 if True else other` inst 169 | | else: 170 | | z = other | |_____________^ SIM108 -171 | +171 | 172 | if False: | = help: Replace `if`-`else`-block with `z = 1 if True else other` @@ -231,13 +229,13 @@ SIM108.py:167:1: SIM108 [*] Use ternary operator `z = 1 if True else other` inst SIM108.py:177:1: SIM108 [*] Use ternary operator `z = True if 1 else other` instead of `if`-`else`-block | 175 | z = other -176 | +176 | 177 | / if 1: 178 | | z = True 179 | | else: 180 | | z = other | |_____________^ SIM108 -181 | +181 | 182 | # SIM108 does not suggest a binary option in this | = help: Replace `if`-`else`-block with `z = True if 1 else other` @@ -264,7 +262,7 @@ SIM108.py:185:1: SIM108 [*] Use ternary operator `z = foo() if foo() else other` 187 | | else: 188 | | z = other | |_____________^ SIM108 -189 | +189 | 190 | # SIM108 does not suggest a binary option in this | = help: Replace `if`-`else`-block with `z = foo() if foo() else other` diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM110.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM110.py.snap index ffbcfb7622c9e..a6899206252de 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM110.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM110.py.snap @@ -1,13 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM110.py:3:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop | 1 | def f(): 2 | # SIM110 -3 | for x in iterable: - | _____^ +3 | / for x in iterable: 4 | | if check(x): 5 | | return True 6 | | return False @@ -31,8 +29,7 @@ SIM110.py:25:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst | 23 | def f(): 24 | # SIM111 -25 | for x in iterable: - | _____^ +25 | / for x in iterable: 26 | | if check(x): 27 | | return False 28 | | return True @@ -57,8 +54,7 @@ SIM110.py:33:5: SIM110 [*] Use `return all(x.is_empty() for x in iterable)` inst | 31 | def f(): 32 | # SIM111 -33 | for x in iterable: - | _____^ +33 | / for x in iterable: 34 | | if not x.is_empty(): 35 | | return False 36 | | return True @@ -83,8 +79,7 @@ SIM110.py:55:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead | 53 | def f(): 54 | # SIM110 -55 | for x in iterable: - | _____^ +55 | / for x in iterable: 56 | | if check(x): 57 | | return True 58 | | else: @@ -111,8 +106,7 @@ SIM110.py:64:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst | 62 | def f(): 63 | # SIM111 -64 | for x in iterable: - | _____^ +64 | / for x in iterable: 65 | | if check(x): 66 | | return False 67 | | else: @@ -139,8 +133,7 @@ SIM110.py:73:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead | 71 | def f(): 72 | # SIM110 -73 | for x in iterable: - | _____^ +73 | / for x in iterable: 74 | | if check(x): 75 | | return True 76 | | else: @@ -168,8 +161,7 @@ SIM110.py:83:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst | 81 | def f(): 82 | # SIM111 -83 | for x in iterable: - | _____^ +83 | / for x in iterable: 84 | | if check(x): 85 | | return False 86 | | else: @@ -196,9 +188,8 @@ SIM110.py:83:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst SIM110.py:124:5: SIM110 Use `return any(check(x) for x in iterable)` instead of `for` loop | 122 | pass -123 | -124 | for x in iterable: - | _____^ +123 | +124 | / for x in iterable: 125 | | if check(x): 126 | | return True 127 | | return False @@ -209,9 +200,8 @@ SIM110.py:124:5: SIM110 Use `return any(check(x) for x in iterable)` instead of SIM110.py:134:5: SIM110 Use `return all(not check(x) for x in iterable)` instead of `for` loop | 132 | pass -133 | -134 | for x in iterable: - | _____^ +133 | +134 | / for x in iterable: 135 | | if check(x): 136 | | return False 137 | | return True @@ -222,8 +212,7 @@ SIM110.py:134:5: SIM110 Use `return all(not check(x) for x in iterable)` instead SIM110.py:144:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop | 143 | # SIM110 -144 | for x in iterable: - | _____^ +144 | / for x in iterable: 145 | | if check(x): 146 | | return True 147 | | return False @@ -247,8 +236,7 @@ SIM110.py:144:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead SIM110.py:154:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop | 153 | # SIM111 -154 | for x in iterable: - | _____^ +154 | / for x in iterable: 155 | | if check(x): 156 | | return False 157 | | return True @@ -273,8 +261,7 @@ SIM110.py:162:5: SIM110 [*] Use `return any(x.isdigit() for x in "012ß9💣2ℝ | 160 | def f(): 161 | # SIM110 -162 | for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ": - | _____^ +162 | / for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ": 163 | | if x.isdigit(): 164 | | return True 165 | | return False @@ -299,13 +286,12 @@ SIM110.py:184:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead | 182 | async def f(): 183 | # SIM110 -184 | for x in iterable: - | _____^ +184 | / for x in iterable: 185 | | if check(x): 186 | | return True 187 | | return False | |________________^ SIM110 -188 | +188 | 189 | async def f(): | = help: Replace with `return any(check(x) for x in iterable)` @@ -327,13 +313,12 @@ SIM110.py:191:5: SIM110 [*] Use `return any(check(x) for x in await iterable)` i | 189 | async def f(): 190 | # SIM110 -191 | for x in await iterable: - | _____^ +191 | / for x in await iterable: 192 | | if check(x): 193 | | return True 194 | | return False | |________________^ SIM110 -195 | +195 | 196 | def f(): | = help: Replace with `return any(check(x) for x in await iterable)` diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM111.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM111.py.snap index 324527ae8736e..82c86ffb8d423 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM111.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM111.py.snap @@ -1,13 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM111.py:3:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop | 1 | def f(): 2 | # SIM110 -3 | for x in iterable: - | _____^ +3 | / for x in iterable: 4 | | if check(x): 5 | | return True 6 | | return False @@ -31,8 +29,7 @@ SIM111.py:25:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst | 23 | def f(): 24 | # SIM111 -25 | for x in iterable: - | _____^ +25 | / for x in iterable: 26 | | if check(x): 27 | | return False 28 | | return True @@ -57,8 +54,7 @@ SIM111.py:33:5: SIM110 [*] Use `return all(x.is_empty() for x in iterable)` inst | 31 | def f(): 32 | # SIM111 -33 | for x in iterable: - | _____^ +33 | / for x in iterable: 34 | | if not x.is_empty(): 35 | | return False 36 | | return True @@ -83,8 +79,7 @@ SIM111.py:55:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead | 53 | def f(): 54 | # SIM110 -55 | for x in iterable: - | _____^ +55 | / for x in iterable: 56 | | if check(x): 57 | | return True 58 | | else: @@ -111,8 +106,7 @@ SIM111.py:64:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst | 62 | def f(): 63 | # SIM111 -64 | for x in iterable: - | _____^ +64 | / for x in iterable: 65 | | if check(x): 66 | | return False 67 | | else: @@ -139,8 +133,7 @@ SIM111.py:73:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead | 71 | def f(): 72 | # SIM110 -73 | for x in iterable: - | _____^ +73 | / for x in iterable: 74 | | if check(x): 75 | | return True 76 | | else: @@ -168,8 +161,7 @@ SIM111.py:83:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst | 81 | def f(): 82 | # SIM111 -83 | for x in iterable: - | _____^ +83 | / for x in iterable: 84 | | if check(x): 85 | | return False 86 | | else: @@ -196,9 +188,8 @@ SIM111.py:83:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst SIM111.py:124:5: SIM110 Use `return any(check(x) for x in iterable)` instead of `for` loop | 122 | pass -123 | -124 | for x in iterable: - | _____^ +123 | +124 | / for x in iterable: 125 | | if check(x): 126 | | return True 127 | | return False @@ -209,9 +200,8 @@ SIM111.py:124:5: SIM110 Use `return any(check(x) for x in iterable)` instead of SIM111.py:134:5: SIM110 Use `return all(not check(x) for x in iterable)` instead of `for` loop | 132 | pass -133 | -134 | for x in iterable: - | _____^ +133 | +134 | / for x in iterable: 135 | | if check(x): 136 | | return False 137 | | return True @@ -222,8 +212,7 @@ SIM111.py:134:5: SIM110 Use `return all(not check(x) for x in iterable)` instead SIM111.py:144:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop | 143 | # SIM110 -144 | for x in iterable: - | _____^ +144 | / for x in iterable: 145 | | if check(x): 146 | | return True 147 | | return False @@ -247,8 +236,7 @@ SIM111.py:144:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead SIM111.py:154:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop | 153 | # SIM111 -154 | for x in iterable: - | _____^ +154 | / for x in iterable: 155 | | if check(x): 156 | | return False 157 | | return True @@ -273,8 +261,7 @@ SIM111.py:162:5: SIM110 [*] Use `return all(x in y for x in iterable)` instead o | 160 | def f(): 161 | # SIM111 -162 | for x in iterable: - | _____^ +162 | / for x in iterable: 163 | | if x not in y: 164 | | return False 165 | | return True @@ -299,8 +286,7 @@ SIM111.py:170:5: SIM110 [*] Use `return all(x <= y for x in iterable)` instead o | 168 | def f(): 169 | # SIM111 -170 | for x in iterable: - | _____^ +170 | / for x in iterable: 171 | | if x > y: 172 | | return False 173 | | return True @@ -325,8 +311,7 @@ SIM111.py:178:5: SIM110 [*] Use `return all(not x.isdigit() for x in "012ß9💣 | 176 | def f(): 177 | # SIM111 -178 | for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9": - | _____^ +178 | / for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9": 179 | | if x.isdigit(): 180 | | return False 181 | | return True diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM114_SIM114.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM114_SIM114.py.snap index 5ff48d7f26783..3e555ee5516be 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM114_SIM114.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM114_SIM114.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM114.py:2:1: SIM114 [*] Combine `if` branches using logical `or` operator | @@ -10,7 +9,7 @@ SIM114.py:2:1: SIM114 [*] Combine `if` branches using logical `or` operator 4 | | elif c: 5 | | b | |_____^ SIM114 -6 | +6 | 7 | if a: # we preserve comments, too! | = help: Combine `if` branches @@ -28,13 +27,13 @@ SIM114.py:2:1: SIM114 [*] Combine `if` branches using logical `or` operator SIM114.py:7:1: SIM114 [*] Combine `if` branches using logical `or` operator | 5 | b - 6 | + 6 | 7 | / if a: # we preserve comments, too! 8 | | b 9 | | elif c: # but not on the second branch 10 | | b | |_____^ SIM114 -11 | +11 | 12 | if x == 1: | = help: Combine `if` branches @@ -54,7 +53,7 @@ SIM114.py:7:1: SIM114 [*] Combine `if` branches using logical `or` operator SIM114.py:12:1: SIM114 [*] Combine `if` branches using logical `or` operator | 10 | b -11 | +11 | 12 | / if x == 1: 13 | | for _ in range(20): 14 | | print("hello") @@ -62,7 +61,7 @@ SIM114.py:12:1: SIM114 [*] Combine `if` branches using logical `or` operator 16 | | for _ in range(20): 17 | | print("hello") | |______________________^ SIM114 -18 | +18 | 19 | if x == 1: | = help: Combine `if` branches @@ -83,7 +82,7 @@ SIM114.py:12:1: SIM114 [*] Combine `if` branches using logical `or` operator SIM114.py:19:1: SIM114 [*] Combine `if` branches using logical `or` operator | 17 | print("hello") -18 | +18 | 19 | / if x == 1: 20 | | if True: 21 | | for _ in range(20): @@ -93,7 +92,7 @@ SIM114.py:19:1: SIM114 [*] Combine `if` branches using logical `or` operator 25 | | for _ in range(20): 26 | | print("hello") | |__________________________^ SIM114 -27 | +27 | 28 | if x == 1: | = help: Combine `if` branches @@ -115,7 +114,7 @@ SIM114.py:19:1: SIM114 [*] Combine `if` branches using logical `or` operator SIM114.py:28:1: SIM114 [*] Combine `if` branches using logical `or` operator | 26 | print("hello") -27 | +27 | 28 | / if x == 1: 29 | | if True: 30 | | for _ in range(20): @@ -131,7 +130,7 @@ SIM114.py:28:1: SIM114 [*] Combine `if` branches using logical `or` operator 40 | | for _ in range(20): 41 | | print("hello") | |__________________________^ SIM114 -42 | +42 | 43 | if ( | = help: Combine `if` branches @@ -156,8 +155,7 @@ SIM114.py:28:1: SIM114 [*] Combine `if` branches using logical `or` operator SIM114.py:29:5: SIM114 [*] Combine `if` branches using logical `or` operator | 28 | if x == 1: -29 | if True: - | _____^ +29 | / if True: 30 | | for _ in range(20): 31 | | print("hello") 32 | | elif False: @@ -186,15 +184,14 @@ SIM114.py:36:5: SIM114 [*] Combine `if` branches using logical `or` operator | 34 | print("hello") 35 | elif x == 2: -36 | if True: - | _____^ +36 | / if True: 37 | | for _ in range(20): 38 | | print("hello") 39 | | elif False: 40 | | for _ in range(20): 41 | | print("hello") | |__________________________^ SIM114 -42 | +42 | 43 | if ( | = help: Combine `if` branches @@ -215,7 +212,7 @@ SIM114.py:36:5: SIM114 [*] Combine `if` branches using logical `or` operator SIM114.py:43:1: SIM114 [*] Combine `if` branches using logical `or` operator | 41 | print("hello") -42 | +42 | 43 | / if ( 44 | | x == 1 45 | | and y == 2 @@ -236,7 +233,7 @@ SIM114.py:43:1: SIM114 [*] Combine `if` branches using logical `or` operator 60 | | elif 1 == 2: 61 | | pass | |________^ SIM114 -62 | +62 | 63 | if result.eofs == "O": | = help: Combine `if` branches @@ -333,8 +330,7 @@ SIM114.py:118:5: SIM114 [*] Combine `if` branches using logical `or` operator | 116 | a = True 117 | b = False -118 | if a > b: # end-of-line - | _____^ +118 | / if a > b: # end-of-line 119 | | return 3 120 | | elif a == b: 121 | | return 3 @@ -360,8 +356,7 @@ SIM114.py:122:5: SIM114 [*] Combine `if` branches using logical `or` operator | 120 | elif a == b: 121 | return 3 -122 | elif a < b: # end-of-line - | _____^ +122 | / elif a < b: # end-of-line 123 | | return 4 124 | | elif b is None: 125 | | return 4 @@ -385,8 +380,7 @@ SIM114.py:132:5: SIM114 [*] Combine `if` branches using logical `or` operator | 130 | a = True 131 | b = False -132 | if a > b: # end-of-line - | _____^ +132 | / if a > b: # end-of-line 133 | | return 3 134 | | elif a := 1: 135 | | return 3 diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM117_SIM117.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM117_SIM117.py.snap index 4d487d8406634..f88cc5274aa99 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM117_SIM117.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM117_SIM117.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM117.py:2:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements | @@ -113,8 +112,7 @@ SIM117.py:53:5: SIM117 [*] Use a single `with` statement with multiple contexts | 51 | while True: 52 | # SIM117 -53 | with A() as a: - | _____^ +53 | / with A() as a: 54 | | with B() as b: | |______________________^ SIM117 55 | """this @@ -277,8 +275,7 @@ SIM117.py:106:5: SIM117 Use a single `with` statement with multiple contexts ins | 104 | # From issue #3025. 105 | async def main(): -106 | async with A() as a: # SIM117. - | _____^ +106 | / async with A() as a: # SIM117. 107 | | async with B() as b: | |____________________________^ SIM117 108 | print("async-inside!") diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM401_SIM401.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM401_SIM401.py.snap index 4a443f22371bb..5b0983df10517 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM401_SIM401.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM401_SIM401.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- SIM401.py:6:1: SIM401 [*] Use `var = a_dict.get(key, "default1")` instead of an `if` block | @@ -10,7 +9,7 @@ SIM401.py:6:1: SIM401 [*] Use `var = a_dict.get(key, "default1")` instead of an 8 | | else: 9 | | var = "default1" | |____________________^ SIM401 -10 | +10 | 11 | # SIM401 (pattern-2) | = help: Replace with `var = a_dict.get(key, "default1")` @@ -36,7 +35,7 @@ SIM401.py:12:1: SIM401 [*] Use `var = a_dict.get(key, "default2")` instead of an 14 | | else: 15 | | var = a_dict[key] | |_____________________^ SIM401 -16 | +16 | 17 | # OK (default contains effect) | = help: Replace with `var = a_dict.get(key, "default2")` @@ -62,7 +61,7 @@ SIM401.py:24:1: SIM401 [*] Use `var = a_dict.get(keys[idx], "default")` instead 26 | | else: 27 | | var = "default" | |___________________^ SIM401 -28 | +28 | 29 | # SIM401 (complex expression in dict) | = help: Replace with `var = a_dict.get(keys[idx], "default")` @@ -88,7 +87,7 @@ SIM401.py:30:1: SIM401 [*] Use `var = dicts[idx].get(key, "default")` instead of 32 | | else: 33 | | var = "default" | |___________________^ SIM401 -34 | +34 | 35 | # SIM401 (complex expression in var) | = help: Replace with `var = dicts[idx].get(key, "default")` @@ -114,7 +113,7 @@ SIM401.py:36:1: SIM401 [*] Use `vars[idx] = a_dict.get(key, "defaultß9💣2ℝ6 38 | | else: 39 | | vars[idx] = "defaultß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789" | |___________________________________________________________________________^ SIM401 -40 | +40 | 41 | # SIM401 | = help: Replace with `vars[idx] = a_dict.get(key, "defaultß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789")` @@ -136,13 +135,12 @@ SIM401.py:45:5: SIM401 [*] Use `vars[idx] = a_dict.get(key, "default")` instead | 43 | pass 44 | else: -45 | if key in a_dict: - | _____^ +45 | / if key in a_dict: 46 | | vars[idx] = a_dict[key] 47 | | else: 48 | | vars[idx] = "default" | |_____________________________^ SIM401 -49 | +49 | 50 | ### | = help: Replace with `vars[idx] = a_dict.get(key, "default")` @@ -165,7 +163,7 @@ SIM401.py:123:7: SIM401 [*] Use `a_dict.get(key, "default3")` instead of an `if` 122 | # SIM401 123 | var = a_dict[key] if key in a_dict else "default3" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM401 -124 | +124 | 125 | # SIM401 | = help: Replace with `a_dict.get(key, "default3")` @@ -185,7 +183,7 @@ SIM401.py:126:7: SIM401 [*] Use `a_dict.get(key, "default-1")` instead of an `if 125 | # SIM401 126 | var = "default-1" if key not in a_dict else a_dict[key] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM401 -127 | +127 | 128 | # OK (default contains effect) | = help: Replace with `a_dict.get(key, "default-1")` diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-cast-value_TC006.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-cast-value_TC006.py.snap index d1691f1fdfb55..ca5dc6f6c1545 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-cast-value_TC006.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-cast-value_TC006.py.snap @@ -4,7 +4,7 @@ source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs TC006.py:4:10: TC006 [*] Add quotes to type expression in `typing.cast()` | 2 | from typing import cast -3 | +3 | 4 | cast(int, 3.0) # TC006 | ^^^ TC006 | @@ -23,7 +23,7 @@ TC006.py:4:10: TC006 [*] Add quotes to type expression in `typing.cast()` TC006.py:10:10: TC006 [*] Add quotes to type expression in `typing.cast()` | 8 | from typing import cast - 9 | + 9 | 10 | cast(list[tuple[bool | float | int | str]], 3.0) # TC006 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TC006 | @@ -42,7 +42,7 @@ TC006.py:10:10: TC006 [*] Add quotes to type expression in `typing.cast()` TC006.py:16:10: TC006 [*] Add quotes to type expression in `typing.cast()` | 14 | from typing import Union, cast -15 | +15 | 16 | cast(list[tuple[Union[bool, float, int, str]]], 3.0) # TC006 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TC006 | @@ -61,7 +61,7 @@ TC006.py:16:10: TC006 [*] Add quotes to type expression in `typing.cast()` TC006.py:40:14: TC006 [*] Add quotes to type expression in `typing.cast()` | 38 | from typing import cast as typecast -39 | +39 | 40 | typecast(int, 3.0) # TC006 | ^^^ TC006 | @@ -80,7 +80,7 @@ TC006.py:40:14: TC006 [*] Add quotes to type expression in `typing.cast()` TC006.py:46:17: TC006 [*] Add quotes to type expression in `typing.cast()` | 44 | import typing -45 | +45 | 46 | typing.cast(int, 3.0) # TC006 | ^^^ TC006 | @@ -99,7 +99,7 @@ TC006.py:46:17: TC006 [*] Add quotes to type expression in `typing.cast()` TC006.py:52:12: TC006 [*] Add quotes to type expression in `typing.cast()` | 50 | import typing as t -51 | +51 | 52 | t.cast(t.Literal["3.0", '3'], 3.0) # TC006 | ^^^^^^^^^^^^^^^^^^^^^ TC006 | @@ -118,8 +118,7 @@ TC006.py:52:12: TC006 [*] Add quotes to type expression in `typing.cast()` TC006.py:59:9: TC006 [*] Add quotes to type expression in `typing.cast()` | 58 | cast( -59 | int # TC006 (unsafe, because it will get rid of this comment) - | _________^ +59 | / int # TC006 (unsafe, because it will get rid of this comment) 60 | | | None, | |______________^ TC006 61 | 3.0 @@ -160,7 +159,7 @@ TC006.py:68:17: TC006 [*] Add quotes to type expression in `typing.cast()` TC006.py:75:10: TC006 [*] Add quotes to type expression in `typing.cast()` | 73 | from typing import cast, Literal -74 | +74 | 75 | cast(Literal["A"], 'A') | ^^^^^^^^^^^^ TC006 | @@ -179,7 +178,7 @@ TC006.py:75:10: TC006 [*] Add quotes to type expression in `typing.cast()` TC006.py:82:10: TC006 [*] Add quotes to type expression in `typing.cast()` | 80 | from typing import cast, Annotated, Literal -81 | +81 | 82 | cast(list[Annotated["list['Literal[\"A\"]']", "Foo"]], ['A']) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TC006 | diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH201_PTH201.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH201_PTH201.py.snap index cc4d0b55a0362..4165133a0177d 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH201_PTH201.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH201_PTH201.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs -snapshot_kind: text --- PTH201.py:6:10: PTH201 [*] Do not pass the current directory explicitly to `Path` | @@ -69,7 +68,7 @@ PTH201.py:9:10: PTH201 [*] Do not pass the current directory explicitly to `Path 8 | _ = PurePath(".") 9 | _ = Path("") | ^^ PTH201 -10 | +10 | 11 | Path('', ) | = help: Remove the current directory argument @@ -87,10 +86,10 @@ PTH201.py:9:10: PTH201 [*] Do not pass the current directory explicitly to `Path PTH201.py:11:6: PTH201 [*] Do not pass the current directory explicitly to `Path` | 9 | _ = Path("") -10 | +10 | 11 | Path('', ) | ^^ PTH201 -12 | +12 | 13 | Path( | = help: Remove the current directory argument @@ -171,8 +170,7 @@ PTH201.py:22:5: PTH201 [*] Do not pass the current directory explicitly to `Path PTH201.py:26:5: PTH201 [*] Do not pass the current directory explicitly to `Path` | 25 | Path( -26 | '' # Comment in the middle of implicitly concatenated string - | _____^ +26 | / '' # Comment in the middle of implicitly concatenated string 27 | | ".", | |_______^ PTH201 28 | ) @@ -281,8 +279,7 @@ PTH201.py:44:5: PTH201 [*] Do not pass the current directory explicitly to `Path PTH201.py:48:5: PTH201 [*] Do not pass the current directory explicitly to `Path` | 47 | ( Path( -48 | '' # Comment in the middle of implicitly concatenated string - | _____^ +48 | / '' # Comment in the middle of implicitly concatenated string 49 | | ".", | |_______^ PTH201 50 | ) )/ (("parenthesized path call") diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__bom_unsorted.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__bom_unsorted.py.snap index 68cceefab1d8f..22eed47081d84 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__bom_unsorted.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__bom_unsorted.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- bom_unsorted.py:1:1: I001 [*] Import block is un-sorted or un-formatted | -1 | import foo - | _^ +1 | / import foo 2 | | import bar + | |___________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__trailing_suffix.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__trailing_suffix.py.snap index c376697885445..df26c70eb1d62 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__trailing_suffix.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__trailing_suffix.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- trailing_suffix.py:1:1: I001 Import block is un-sorted or un-formatted | 1 | / import sys 2 | | import os; x = 1 | |_________^ I001 -3 | +3 | 4 | if True: | = help: Organize imports @@ -15,8 +14,7 @@ trailing_suffix.py:1:1: I001 Import block is un-sorted or un-formatted trailing_suffix.py:5:5: I001 Import block is un-sorted or un-formatted | 4 | if True: -5 | import sys - | _____^ +5 | / import sys 6 | | import os; x = 1 | |_____________^ I001 | diff --git a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF203_PERF203.py.snap b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF203_PERF203.py.snap index d7839484b732a..f0cc3e1d1fcd4 100644 --- a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF203_PERF203.py.snap +++ b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF203_PERF203.py.snap @@ -1,15 +1,13 @@ --- source: crates/ruff_linter/src/rules/perflint/mod.rs -snapshot_kind: text --- PERF203.py:5:5: PERF203 `try`-`except` within a loop incurs performance overhead | 3 | try: 4 | print(f"{i}") -5 | except: - | _____^ +5 | / except: 6 | | print("error") | |______________________^ PERF203 -7 | +7 | 8 | # OK | diff --git a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF401_PERF401.py.snap b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF401_PERF401.py.snap index 8a660dd70938f..d21c46905a8f2 100644 --- a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF401_PERF401.py.snap +++ b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF401_PERF401.py.snap @@ -151,8 +151,7 @@ PERF401.py:210:13: PERF401 Use a list comprehension to create a transformed list | 208 | ): # Comment 3 209 | if i % 2: # Comment 4 -210 | result.append( - | _____________^ +210 | / result.append( 211 | | ( 212 | | i + 1, 213 | | # Comment 5 @@ -188,7 +187,7 @@ PERF401.py:239:9: PERF401 Use a list comprehension to create a transformed list 238 | for a in values: 239 | result.append(a + 1) # PERF401 | ^^^^^^^^^^^^^^^^^^^^ PERF401 -240 | +240 | 241 | def f(): | = help: Replace for loop with list comprehension diff --git a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__preview__PERF401_PERF401.py.snap b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__preview__PERF401_PERF401.py.snap index dda14552ee4a4..ff568d18219eb 100644 --- a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__preview__PERF401_PERF401.py.snap +++ b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__preview__PERF401_PERF401.py.snap @@ -355,8 +355,7 @@ PERF401.py:210:13: PERF401 [*] Use a list comprehension to create a transformed | 208 | ): # Comment 3 209 | if i % 2: # Comment 4 -210 | result.append( - | _____________^ +210 | / result.append( 211 | | ( 212 | | i + 1, 213 | | # Comment 5 @@ -447,7 +446,7 @@ PERF401.py:239:9: PERF401 [*] Use a list comprehension to create a transformed l 238 | for a in values: 239 | result.append(a + 1) # PERF401 | ^^^^^^^^^^^^^^^^^^^^ PERF401 -240 | +240 | 241 | def f(): | = help: Replace for loop with list comprehension diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E731_E731.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E731_E731.py.snap index fdc897617e3dd..775ca06ecbaab 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E731_E731.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E731_E731.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E731.py:3:5: E731 [*] Do not assign a `lambda` expression, use a `def` | @@ -187,7 +186,7 @@ E731.py:86:5: E731 [*] Do not assign a `lambda` expression, use a `def` E731.py:94:5: E731 [*] Do not assign a `lambda` expression, use a `def` | 92 | from typing import Callable -93 | +93 | 94 | f: Callable[[], None] = lambda: None | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 | @@ -207,7 +206,7 @@ E731.py:94:5: E731 [*] Do not assign a `lambda` expression, use a `def` E731.py:102:5: E731 [*] Do not assign a `lambda` expression, use a `def` | 100 | from typing import Callable -101 | +101 | 102 | f: Callable[..., None] = lambda a, b: None | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 | @@ -227,7 +226,7 @@ E731.py:102:5: E731 [*] Do not assign a `lambda` expression, use a `def` E731.py:110:5: E731 [*] Do not assign a `lambda` expression, use a `def` | 108 | from typing import Callable -109 | +109 | 110 | f: Callable[[int], int] = lambda x: 2 * x | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 | @@ -247,7 +246,7 @@ E731.py:110:5: E731 [*] Do not assign a `lambda` expression, use a `def` E731.py:119:5: E731 [*] Do not assign a `lambda` expression, use a `def` | 117 | from collections.abc import Callable -118 | +118 | 119 | f: Callable[[str, int], str] = lambda a, b: a * b | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 | @@ -267,7 +266,7 @@ E731.py:119:5: E731 [*] Do not assign a `lambda` expression, use a `def` E731.py:127:5: E731 [*] Do not assign a `lambda` expression, use a `def` | 125 | from collections.abc import Callable -126 | +126 | 127 | f: Callable[[str, int], tuple[str, int]] = lambda a, b: (a, b) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 | @@ -287,7 +286,7 @@ E731.py:127:5: E731 [*] Do not assign a `lambda` expression, use a `def` E731.py:135:5: E731 [*] Do not assign a `lambda` expression, use a `def` | 133 | from collections.abc import Callable -134 | +134 | 135 | f: Callable[[str, int, list[str]], list[str]] = lambda a, b, /, c: [*c, a * b] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 | @@ -347,9 +346,8 @@ E731.py:140:5: E731 Do not assign a `lambda` expression, use a `def` E731.py:147:5: E731 [*] Do not assign a `lambda` expression, use a `def` | 145 | # E731 -146 | -147 | f = lambda: ( - | _____^ +146 | +147 | / f = lambda: ( 148 | | i := 1, 149 | | ) | |_____^ E731 @@ -380,7 +378,7 @@ E731.py:163:1: E731 [*] Do not assign a `lambda` expression, use a `def` 165 | | b 166 | | """ | |___^ E731 -167 | +167 | 168 | # * https://github.com/astral-sh/ruff/issues/10277 | = help: Rewrite `x` as a `def` @@ -401,7 +399,7 @@ E731.py:169:1: E731 [*] Do not assign a `lambda` expression, use a `def` 168 | # * https://github.com/astral-sh/ruff/issues/10277 169 | at_least_one_million = lambda _: _ >= 1_000_000 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 -170 | +170 | 171 | x = lambda: ( | = help: Rewrite `at_least_one_million` as a `def` @@ -420,13 +418,13 @@ E731.py:169:1: E731 [*] Do not assign a `lambda` expression, use a `def` E731.py:171:1: E731 [*] Do not assign a `lambda` expression, use a `def` | 169 | at_least_one_million = lambda _: _ >= 1_000_000 -170 | +170 | 171 | / x = lambda: ( 172 | | # comment 173 | | 5 + 10 174 | | ) | |_^ E731 -175 | +175 | 176 | x = lambda: ( | = help: Rewrite `x` as a `def` @@ -445,7 +443,7 @@ E731.py:171:1: E731 [*] Do not assign a `lambda` expression, use a `def` E731.py:176:1: E731 [*] Do not assign a `lambda` expression, use a `def` | 174 | ) -175 | +175 | 176 | / x = lambda: ( 177 | | # comment 178 | | y := 10 diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-exception_DOC502_google.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-exception_DOC502_google.py.snap index f92c339f8a29a..c8473308908cf 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-exception_DOC502_google.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-exception_DOC502_google.py.snap @@ -1,21 +1,19 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs -snapshot_kind: text --- DOC502_google.py:7:5: DOC502 Raised exception is not explicitly raised: `FasterThanLightError` | 5 | # DOC502 6 | def calculate_speed(distance: float, time: float) -> float: - 7 | """Calculate speed as distance divided by time. - | _____^ - 8 | | + 7 | / """Calculate speed as distance divided by time. + 8 | | 9 | | Args: 10 | | distance: Distance traveled. 11 | | time: Time spent traveling. -12 | | +12 | | 13 | | Returns: 14 | | Speed as distance divided by time. -15 | | +15 | | 16 | | Raises: 17 | | FasterThanLightError: If speed is greater than the speed of light. 18 | | """ @@ -28,16 +26,15 @@ DOC502_google.py:24:5: DOC502 Raised exceptions are not explicitly raised: `Fast | 22 | # DOC502 23 | def calculate_speed(distance: float, time: float) -> float: -24 | """Calculate speed as distance divided by time. - | _____^ -25 | | +24 | / """Calculate speed as distance divided by time. +25 | | 26 | | Args: 27 | | distance: Distance traveled. 28 | | time: Time spent traveling. -29 | | +29 | | 30 | | Returns: 31 | | Speed as distance divided by time. -32 | | +32 | | 33 | | Raises: 34 | | FasterThanLightError: If speed is greater than the speed of light. 35 | | DivisionByZero: Divide by zero. @@ -51,16 +48,15 @@ DOC502_google.py:42:5: DOC502 Raised exception is not explicitly raised: `Divisi | 40 | # DOC502 41 | def calculate_speed(distance: float, time: float) -> float: -42 | """Calculate speed as distance divided by time. - | _____^ -43 | | +42 | / """Calculate speed as distance divided by time. +43 | | 44 | | Args: 45 | | distance: Distance traveled. 46 | | time: Time spent traveling. -47 | | +47 | | 48 | | Returns: 49 | | Speed as distance divided by time. -50 | | +50 | | 51 | | Raises: 52 | | FasterThanLightError: If speed is greater than the speed of light. 53 | | DivisionByZero: Divide by zero. diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-exception_DOC502_numpy.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-exception_DOC502_numpy.py.snap index d1ec87e09f150..b007d9536bc5c 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-exception_DOC502_numpy.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-exception_DOC502_numpy.py.snap @@ -1,27 +1,25 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs -snapshot_kind: text --- DOC502_numpy.py:7:5: DOC502 Raised exception is not explicitly raised: `FasterThanLightError` | 5 | # DOC502 6 | def calculate_speed(distance: float, time: float) -> float: - 7 | """ - | _____^ + 7 | / """ 8 | | Calculate speed as distance divided by time. - 9 | | + 9 | | 10 | | Parameters 11 | | ---------- 12 | | distance : float 13 | | Distance traveled. 14 | | time : float 15 | | Time spent traveling. -16 | | +16 | | 17 | | Returns 18 | | ------- 19 | | float 20 | | Speed as distance divided by time. -21 | | +21 | | 22 | | Raises 23 | | ------ 24 | | FasterThanLightError @@ -36,22 +34,21 @@ DOC502_numpy.py:32:5: DOC502 Raised exceptions are not explicitly raised: `Faste | 30 | # DOC502 31 | def calculate_speed(distance: float, time: float) -> float: -32 | """ - | _____^ +32 | / """ 33 | | Calculate speed as distance divided by time. -34 | | +34 | | 35 | | Parameters 36 | | ---------- 37 | | distance : float 38 | | Distance traveled. 39 | | time : float 40 | | Time spent traveling. -41 | | +41 | | 42 | | Returns 43 | | ------- 44 | | float 45 | | Speed as distance divided by time. -46 | | +46 | | 47 | | Raises 48 | | ------ 49 | | FasterThanLightError @@ -68,22 +65,21 @@ DOC502_numpy.py:59:5: DOC502 Raised exception is not explicitly raised: `Divisio | 57 | # DOC502 58 | def calculate_speed(distance: float, time: float) -> float: -59 | """ - | _____^ +59 | / """ 60 | | Calculate speed as distance divided by time. -61 | | +61 | | 62 | | Parameters 63 | | ---------- 64 | | distance : float 65 | | Distance traveled. 66 | | time : float 67 | | Time spent traveling. -68 | | +68 | | 69 | | Returns 70 | | ------- 71 | | float 72 | | Speed as distance divided by time. -73 | | +73 | | 74 | | Raises 75 | | ------ 76 | | FasterThanLightError diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-returns_DOC202_google.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-returns_DOC202_google.py.snap index ce711cd2f33a2..70beeffbc12e4 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-returns_DOC202_google.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-returns_DOC202_google.py.snap @@ -1,18 +1,16 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs -snapshot_kind: text --- DOC202_google.py:14:5: DOC202 Docstring should not have a returns section because the function doesn't return anything | 12 | # DOC202 13 | def foo(num: int) -> str: -14 | """ - | _____^ +14 | / """ 15 | | Do something -16 | | +16 | | 17 | | Args: 18 | | num (int): A number -19 | | +19 | | 20 | | Returns: 21 | | str: A string 22 | | """ @@ -25,13 +23,12 @@ DOC202_google.py:30:9: DOC202 Docstring should not have a returns section becaus | 28 | # DOC202 29 | def foo(self) -> str: -30 | """ - | _________^ +30 | / """ 31 | | Do something -32 | | +32 | | 33 | | Args: 34 | | num (int): A number -35 | | +35 | | 36 | | Returns: 37 | | str: A string 38 | | """ @@ -44,9 +41,8 @@ DOC202_google.py:80:5: DOC202 Docstring should not have a returns section becaus | 78 | # DOC202 -- never explicitly returns anything, just short-circuits 79 | def foo(s: str, condition: bool): -80 | """Fooey things. - | _____^ -81 | | +80 | / """Fooey things. +81 | | 82 | | Returns: 83 | | None 84 | | """ diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-returns_DOC202_numpy.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-returns_DOC202_numpy.py.snap index 9dd72771bbd22..0bb06b9b99021 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-returns_DOC202_numpy.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-returns_DOC202_numpy.py.snap @@ -1,20 +1,18 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs -snapshot_kind: text --- DOC202_numpy.py:16:5: DOC202 Docstring should not have a returns section because the function doesn't return anything | 14 | # DOC202 15 | def foo(num: int) -> str: -16 | """ - | _____^ +16 | / """ 17 | | Do something -18 | | +18 | | 19 | | Parameters 20 | | ---------- 21 | | num : int 22 | | A number -23 | | +23 | | 24 | | Returns 25 | | ------- 26 | | str @@ -29,15 +27,14 @@ DOC202_numpy.py:36:9: DOC202 Docstring should not have a returns section because | 34 | # DOC202 35 | def foo(self) -> str: -36 | """ - | _________^ +36 | / """ 37 | | Do something -38 | | +38 | | 39 | | Parameters 40 | | ---------- 41 | | num : int 42 | | A number -43 | | +43 | | 44 | | Returns 45 | | ------- 46 | | str diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-yields_DOC403_google.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-yields_DOC403_google.py.snap index fa9fa2d420395..dccb259a11ed0 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-yields_DOC403_google.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-yields_DOC403_google.py.snap @@ -1,18 +1,16 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs -snapshot_kind: text --- DOC403_google.py:14:5: DOC403 Docstring has a "Yields" section but the function doesn't yield anything | 12 | # DOC403 13 | def foo(num: int) -> str: -14 | """ - | _____^ +14 | / """ 15 | | Do something -16 | | +16 | | 17 | | Args: 18 | | num (int): A number -19 | | +19 | | 20 | | Yields: 21 | | str: A string 22 | | """ @@ -25,13 +23,12 @@ DOC403_google.py:30:9: DOC403 Docstring has a "Yields" section but the function | 28 | # DOC403 29 | def foo(self) -> str: -30 | """ - | _________^ +30 | / """ 31 | | Do something -32 | | +32 | | 33 | | Args: 34 | | num (int): A number -35 | | +35 | | 36 | | Yields: 37 | | str: A string 38 | | """ diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-yields_DOC403_numpy.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-yields_DOC403_numpy.py.snap index db9846a14252d..d87e8f4f27c40 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-yields_DOC403_numpy.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-yields_DOC403_numpy.py.snap @@ -1,20 +1,18 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs -snapshot_kind: text --- DOC403_numpy.py:16:5: DOC403 Docstring has a "Yields" section but the function doesn't yield anything | 14 | # DOC403 15 | def foo(num: int) -> str: -16 | """ - | _____^ +16 | / """ 17 | | Do something -18 | | +18 | | 19 | | Parameters 20 | | ---------- 21 | | num : int 22 | | A number -23 | | +23 | | 24 | | Yields 25 | | ------- 26 | | str @@ -29,15 +27,14 @@ DOC403_numpy.py:36:9: DOC403 Docstring has a "Yields" section but the function d | 34 | # DOC403 35 | def foo(self) -> str: -36 | """ - | _________^ +36 | / """ 37 | | Do something -38 | | +38 | | 39 | | Parameters 40 | | ---------- 41 | | num : int 42 | | A number -43 | | +43 | | 44 | | Yields 45 | | ------- 46 | | str diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-exception_DOC501_google.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-exception_DOC501_google.py.snap index 2b072233ab36f..b30b47f6f7efc 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-exception_DOC501_google.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-exception_DOC501_google.py.snap @@ -1,18 +1,16 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs -snapshot_kind: text --- DOC501_google.py:34:5: DOC501 Raised exception `FasterThanLightError` missing from docstring | 32 | # DOC501 33 | def calculate_speed(distance: float, time: float) -> float: -34 | """Calculate speed as distance divided by time. - | _____^ -35 | | +34 | / """Calculate speed as distance divided by time. +35 | | 36 | | Args: 37 | | distance: Distance traveled. 38 | | time: Time spent traveling. -39 | | +39 | | 40 | | Returns: 41 | | Speed as distance divided by time. 42 | | """ @@ -26,13 +24,12 @@ DOC501_google.py:51:5: DOC501 Raised exception `ValueError` missing from docstri | 49 | # DOC501 50 | def calculate_speed(distance: float, time: float) -> float: -51 | """Calculate speed as distance divided by time. - | _____^ -52 | | +51 | / """Calculate speed as distance divided by time. +52 | | 53 | | Args: 54 | | distance: Distance traveled. 55 | | time: Time spent traveling. -56 | | +56 | | 57 | | Returns: 58 | | Speed as distance divided by time. 59 | | """ @@ -46,13 +43,12 @@ DOC501_google.py:51:5: DOC501 Raised exception `FasterThanLightError` missing fr | 49 | # DOC501 50 | def calculate_speed(distance: float, time: float) -> float: -51 | """Calculate speed as distance divided by time. - | _____^ -52 | | +51 | / """Calculate speed as distance divided by time. +52 | | 53 | | Args: 54 | | distance: Distance traveled. 55 | | time: Time spent traveling. -56 | | +56 | | 57 | | Returns: 58 | | Speed as distance divided by time. 59 | | """ @@ -66,13 +62,12 @@ DOC501_google.py:106:5: DOC501 Raised exception `AnotherError` missing from docs | 104 | # DOC501 105 | def calculate_speed(distance: float, time: float) -> float: -106 | """Calculate speed as distance divided by time. - | _____^ -107 | | +106 | / """Calculate speed as distance divided by time. +107 | | 108 | | Args: 109 | | distance: Distance traveled. 110 | | time: Time spent traveling. -111 | | +111 | | 112 | | Returns: 113 | | Speed as distance divided by time. 114 | | """ @@ -85,13 +80,12 @@ DOC501_google.py:120:5: DOC501 Raised exception `AnotherError` missing from docs | 118 | # DOC501 119 | def calculate_speed(distance: float, time: float) -> float: -120 | """Calculate speed as distance divided by time. - | _____^ -121 | | +120 | / """Calculate speed as distance divided by time. +121 | | 122 | | Args: 123 | | distance: Distance traveled. 124 | | time: Time spent traveling. -125 | | +125 | | 126 | | Returns: 127 | | Speed as distance divided by time. 128 | | """ @@ -104,9 +98,8 @@ DOC501_google.py:134:5: DOC501 Raised exception `SomeError` missing from docstri | 132 | # DOC501 133 | def foo(bar: int): -134 | """Foo. - | _____^ -135 | | +134 | / """Foo. +135 | | 136 | | Args: 137 | | bar: Bar. 138 | | """ @@ -119,16 +112,15 @@ DOC501_google.py:197:5: DOC501 Raised exception `ZeroDivisionError` missing from | 195 | # DOC501 196 | def calculate_speed(distance: float, time: float) -> float: -197 | """Calculate speed as distance divided by time. - | _____^ -198 | | +197 | / """Calculate speed as distance divided by time. +198 | | 199 | | Args: 200 | | distance: Distance traveled. 201 | | time: Time spent traveling. -202 | | +202 | | 203 | | Returns: 204 | | Speed as distance divided by time. -205 | | +205 | | 206 | | Raises: 207 | | TypeError: if you didn't pass a number for both parameters 208 | | """ @@ -141,9 +133,8 @@ DOC501_google.py:197:5: DOC501 Raised exception `ZeroDivisionError` missing from DOC501_google.py:238:5: DOC501 Raised exception `TypeError` missing from docstring | 237 | def foo(): -238 | """Foo. - | _____^ -239 | | +238 | / """Foo. +239 | | 240 | | Returns: 241 | | 42: int. 242 | | """ @@ -156,9 +147,8 @@ DOC501_google.py:238:5: DOC501 Raised exception `TypeError` missing from docstri DOC501_google.py:238:5: DOC501 Raised exception `ValueError` missing from docstring | 237 | def foo(): -238 | """Foo. - | _____^ -239 | | +238 | / """Foo. +239 | | 240 | | Returns: 241 | | 42: int. 242 | | """ diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-exception_DOC501_numpy.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-exception_DOC501_numpy.py.snap index 3622a572b4c5d..1a53bef11f492 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-exception_DOC501_numpy.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-exception_DOC501_numpy.py.snap @@ -1,22 +1,20 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs -snapshot_kind: text --- DOC501_numpy.py:35:5: DOC501 Raised exception `FasterThanLightError` missing from docstring | 33 | # DOC501 34 | def calculate_speed(distance: float, time: float) -> float: -35 | """ - | _____^ +35 | / """ 36 | | Calculate speed as distance divided by time. -37 | | +37 | | 38 | | Parameters 39 | | ---------- 40 | | distance : float 41 | | Distance traveled. 42 | | time : float 43 | | Time spent traveling. -44 | | +44 | | 45 | | Returns 46 | | ------- 47 | | float @@ -32,17 +30,16 @@ DOC501_numpy.py:58:5: DOC501 Raised exception `ValueError` missing from docstrin | 56 | # DOC501 57 | def calculate_speed(distance: float, time: float) -> float: -58 | """ - | _____^ +58 | / """ 59 | | Calculate speed as distance divided by time. -60 | | +60 | | 61 | | Parameters 62 | | ---------- 63 | | distance : float 64 | | Distance traveled. 65 | | time : float 66 | | Time spent traveling. -67 | | +67 | | 68 | | Returns 69 | | ------- 70 | | float @@ -58,17 +55,16 @@ DOC501_numpy.py:58:5: DOC501 Raised exception `FasterThanLightError` missing fro | 56 | # DOC501 57 | def calculate_speed(distance: float, time: float) -> float: -58 | """ - | _____^ +58 | / """ 59 | | Calculate speed as distance divided by time. -60 | | +60 | | 61 | | Parameters 62 | | ---------- 63 | | distance : float 64 | | Distance traveled. 65 | | time : float 66 | | Time spent traveling. -67 | | +67 | | 68 | | Returns 69 | | ------- 70 | | float @@ -84,23 +80,22 @@ DOC501_numpy.py:83:5: DOC501 Raised exception `TypeError` missing from docstring | 81 | # DOC501 82 | def calculate_speed(distance: float, time: float) -> float: - 83 | """Calculate speed as distance divided by time. - | _____^ - 84 | | + 83 | / """Calculate speed as distance divided by time. + 84 | | 85 | | ACalculate speed as distance divided by time. - 86 | | + 86 | | 87 | | Parameters 88 | | ---------- 89 | | distance : float 90 | | Distance traveled. 91 | | time : float 92 | | Time spent traveling. - 93 | | + 93 | | 94 | | Returns 95 | | ------- 96 | | float 97 | | Speed as distance divided by time. - 98 | | + 98 | | 99 | | Raises 100 | | ------ 101 | | ZeroDivisionError @@ -115,9 +110,8 @@ DOC501_numpy.py:83:5: DOC501 Raised exception `TypeError` missing from docstring DOC501_numpy.py:139:5: DOC501 Raised exception `TypeError` missing from docstring | 138 | def foo(): -139 | """Foo. - | _____^ -140 | | +139 | / """Foo. +140 | | 141 | | Returns 142 | | ------- 143 | | int @@ -132,9 +126,8 @@ DOC501_numpy.py:139:5: DOC501 Raised exception `TypeError` missing from docstrin DOC501_numpy.py:139:5: DOC501 Raised exception `ValueError` missing from docstring | 138 | def foo(): -139 | """Foo. - | _____^ -140 | | +139 | / """Foo. +140 | | 141 | | Returns 142 | | ------- 143 | | int diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-returns_DOC201_google.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-returns_DOC201_google.py.snap index ec835deb8b160..d074c173669c6 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-returns_DOC201_google.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-returns_DOC201_google.py.snap @@ -1,15 +1,13 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs -snapshot_kind: text --- DOC201_google.py:3:5: DOC201 `return` is not documented in docstring | 1 | # DOC201 2 | def foo(num: int) -> str: -3 | """ - | _____^ +3 | / """ 4 | | Do something -5 | | +5 | | 6 | | Args: 7 | | num (int): A number 8 | | """ @@ -22,10 +20,9 @@ DOC201_google.py:44:9: DOC201 `return` is not documented in docstring | 42 | # DOC201 43 | def bar(self) -> str: -44 | """ - | _________^ +44 | / """ 45 | | Do something -46 | | +46 | | 47 | | Args: 48 | | num (int): A number 49 | | """ @@ -58,9 +55,8 @@ DOC201_google.py:178:5: DOC201 `return` is not documented in docstring | 176 | # DOC201 - non-early return explicit None 177 | def foo(x: int) -> int | None: -178 | """A very helpful docstring. - | _____^ -179 | | +178 | / """A very helpful docstring. +179 | | 180 | | Args: 181 | | x (int): An integer. 182 | | """ @@ -74,9 +70,8 @@ DOC201_google.py:191:5: DOC201 `return` is not documented in docstring | 189 | # DOC201 - non-early return explicit None w/o useful type annotations 190 | def foo(x): -191 | """A very helpful docstring. - | _____^ -192 | | +191 | / """A very helpful docstring. +192 | | 193 | | Args: 194 | | x (int): An integer. 195 | | """ @@ -90,9 +85,8 @@ DOC201_google.py:204:5: DOC201 `return` is not documented in docstring | 202 | # DOC201 - only returns None, but return annotation is not None 203 | def foo(s: str) -> str | None: -204 | """A very helpful docstring. - | _____^ -205 | | +204 | / """A very helpful docstring. +205 | | 206 | | Args: 207 | | s (str): A string. 208 | | """ diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-returns_DOC201_numpy.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-returns_DOC201_numpy.py.snap index 7e4fab9e978b5..b1b707127557c 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-returns_DOC201_numpy.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-returns_DOC201_numpy.py.snap @@ -1,15 +1,13 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs -snapshot_kind: text --- DOC201_numpy.py:3:5: DOC201 `return` is not documented in docstring | 1 | # DOC201 2 | def foo(num: int) -> str: - 3 | """ - | _____^ + 3 | / """ 4 | | Do something - 5 | | + 5 | | 6 | | Parameters 7 | | ---------- 8 | | num : int @@ -24,10 +22,9 @@ DOC201_numpy.py:54:9: DOC201 `return` is not documented in docstring | 52 | # DOC201 53 | def bar(self) -> str: -54 | """ - | _________^ +54 | / """ 55 | | Do something -56 | | +56 | | 57 | | Parameters 58 | | ---------- 59 | | num : int @@ -52,9 +49,8 @@ DOC201_numpy.py:152:5: DOC201 `return` is not documented in docstring | 150 | # DOC201 - non-early return explicit None 151 | def foo(x: int) -> int | None: -152 | """A very helpful docstring. - | _____^ -153 | | +152 | / """A very helpful docstring. +153 | | 154 | | Parameters 155 | | ---------- 156 | | x : int @@ -70,9 +66,8 @@ DOC201_numpy.py:167:5: DOC201 `return` is not documented in docstring | 165 | # DOC201 - non-early return explicit None w/o useful type annotations 166 | def foo(x): -167 | """A very helpful docstring. - | _____^ -168 | | +167 | / """A very helpful docstring. +168 | | 169 | | Parameters 170 | | ---------- 171 | | x : int @@ -88,9 +83,8 @@ DOC201_numpy.py:182:5: DOC201 `return` is not documented in docstring | 180 | # DOC201 - only returns None, but return annotation is not None 181 | def foo(s: str) -> str | None: -182 | """A very helpful docstring. - | _____^ -183 | | +182 | / """A very helpful docstring. +183 | | 184 | | Parameters 185 | | ---------- 186 | | x : str diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-yields_DOC402_google.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-yields_DOC402_google.py.snap index 2adc0bd1d4713..0f1e8d89884e9 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-yields_DOC402_google.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-yields_DOC402_google.py.snap @@ -1,15 +1,13 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs -snapshot_kind: text --- DOC402_google.py:3:5: DOC402 `yield` is not documented in docstring | 1 | # DOC402 2 | def foo(num: int) -> str: -3 | """ - | _____^ +3 | / """ 4 | | Do something -5 | | +5 | | 6 | | Args: 7 | | num (int): A number 8 | | """ @@ -22,10 +20,9 @@ DOC402_google.py:44:9: DOC402 `yield` is not documented in docstring | 42 | # DOC402 43 | def bar(self) -> str: -44 | """ - | _________^ +44 | / """ 45 | | Do something -46 | | +46 | | 47 | | Args: 48 | | num (int): A number 49 | | """ @@ -58,8 +55,7 @@ DOC402_google.py:97:5: DOC402 `yield` is not documented in docstring | 95 | # DOC402 96 | def foo() -> collections.abc.Generator[int | None, None, None]: - 97 | """ - | _____^ + 97 | / """ 98 | | Do something 99 | | """ | |_______^ DOC402 @@ -71,8 +67,7 @@ DOC402_google.py:105:5: DOC402 `yield` is not documented in docstring | 103 | # DOC402 104 | def bar() -> collections.abc.Iterator[int | None]: -105 | """ - | _____^ +105 | / """ 106 | | Do something 107 | | """ | |_______^ DOC402 diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-yields_DOC402_numpy.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-yields_DOC402_numpy.py.snap index 5030f0f8142cf..6089267205b36 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-yields_DOC402_numpy.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-yields_DOC402_numpy.py.snap @@ -1,15 +1,13 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs -snapshot_kind: text --- DOC402_numpy.py:3:5: DOC402 `yield` is not documented in docstring | 1 | # DOC402 2 | def foo(num: int) -> str: - 3 | """ - | _____^ + 3 | / """ 4 | | Do something - 5 | | + 5 | | 6 | | Parameters 7 | | ---------- 8 | | num : int @@ -24,10 +22,9 @@ DOC402_numpy.py:54:9: DOC402 `yield` is not documented in docstring | 52 | # DOC402 53 | def bar(self) -> str: -54 | """ - | _________^ +54 | / """ 55 | | Do something -56 | | +56 | | 57 | | Parameters 58 | | ---------- 59 | | num : int @@ -42,8 +39,7 @@ DOC402_numpy.py:86:5: DOC402 `yield` is not documented in docstring | 84 | # DOC402 85 | def foo() -> typing.Generator[int | None, None, None]: -86 | """ - | _____^ +86 | / """ 87 | | Do something 88 | | """ | |_______^ DOC402 @@ -56,8 +52,7 @@ DOC402_numpy.py:95:5: DOC402 `yield` is not documented in docstring | 93 | # DOC402 94 | def foo() -> typing.Generator[int, None, None]: -95 | """ - | _____^ +95 | / """ 96 | | Do something 97 | | """ | |_______^ DOC402 @@ -69,8 +64,7 @@ DOC402_numpy.py:119:5: DOC402 `yield` is not documented in docstring | 117 | # DOC402 118 | def foo(): -119 | """ - | _____^ +119 | / """ 120 | | Do something 121 | | """ | |_______^ DOC402 @@ -83,8 +77,7 @@ DOC402_numpy.py:128:5: DOC402 `yield` is not documented in docstring | 126 | # DOC402 127 | def foo(): -128 | """ - | _____^ +128 | / """ 129 | | Do something 130 | | """ | |_______^ DOC402 @@ -97,8 +90,7 @@ DOC402_numpy.py:137:5: DOC402 `yield` is not documented in docstring | 135 | # DOC402 136 | def bar() -> typing.Iterator[int | None]: -137 | """ - | _____^ +137 | / """ 138 | | Do something 139 | | """ | |_______^ DOC402 diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D.py.snap index 762a737fc14dc..da2a88322f367 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D.py.snap @@ -1,13 +1,11 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D.py:129:5: D200 [*] One-line docstring should fit on one line | 127 | @expect('D212: Multi-line docstring summary should start at the first line') 128 | def asdlkfasd(): -129 | """ - | _____^ +129 | / """ 130 | | Wrong. 131 | | """ | |_______^ D200 @@ -30,9 +28,8 @@ D.py:597:5: D200 [*] One-line docstring should fit on one line | 595 | @expect('D212: Multi-line docstring summary should start at the first line') 596 | def one_liner(): -597 | """ - | _____^ -598 | | +597 | / """ +598 | | 599 | | Wrong.""" | |_____________^ D200 | @@ -54,9 +51,8 @@ D.py:606:5: D200 [*] One-line docstring should fit on one line | 604 | @expect('D212: Multi-line docstring summary should start at the first line') 605 | def one_liner(): -606 | r"""Wrong. - | _____^ -607 | | +606 | / r"""Wrong. +607 | | 608 | | """ | |_______^ D200 | @@ -78,9 +74,8 @@ D.py:615:5: D200 One-line docstring should fit on one line | 613 | @expect('D212: Multi-line docstring summary should start at the first line') 614 | def one_liner(): -615 | """Wrong." - | _____^ -616 | | +615 | / """Wrong." +616 | | 617 | | """ | |_______^ D200 | @@ -90,9 +85,8 @@ D.py:624:5: D200 One-line docstring should fit on one line | 622 | @expect('D212: Multi-line docstring summary should start at the first line') 623 | def one_liner(): -624 | """ - | _____^ -625 | | +624 | / """ +625 | | 626 | | "Wrong.""" | |______________^ D200 | @@ -101,11 +95,10 @@ D.py:624:5: D200 One-line docstring should fit on one line D.py:645:5: D200 One-line docstring should fit on one line | 644 | def single_line_docstring_with_an_escaped_backslash(): -645 | "\ - | _____^ +645 | / "\ 646 | | " | |_____^ D200 -647 | +647 | 648 | class StatementOnSameLineAsDocstring: | = help: Reformat to one line diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D200.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D200.py.snap index ffd1817a77754..5a77be745414f 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D200.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D200.py.snap @@ -1,12 +1,10 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D200.py:2:5: D200 One-line docstring should fit on one line | 1 | def func(): -2 | """\ - | _____^ +2 | / """\ 3 | | """ | |_______^ D200 | @@ -15,8 +13,7 @@ D200.py:2:5: D200 One-line docstring should fit on one line D200.py:7:5: D200 [*] One-line docstring should fit on one line | 6 | def func(): -7 | """\\ - | _____^ +7 | / """\\ 8 | | """ | |_______^ D200 | @@ -36,8 +33,7 @@ D200.py:7:5: D200 [*] One-line docstring should fit on one line D200.py:12:5: D200 One-line docstring should fit on one line | 11 | def func(): -12 | """\ \ - | _____^ +12 | / """\ \ 13 | | """ | |_______^ D200 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D201_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D201_D.py.snap index 50dc738c547ac..b22486d55a9db 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D201_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D201_D.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D.py:137:5: D201 [*] No blank lines allowed before function docstring (found 1) | 135 | def leading_space(): -136 | +136 | 137 | """Leading space.""" | ^^^^^^^^^^^^^^^^^^^^ D201 | @@ -23,10 +22,10 @@ D.py:137:5: D201 [*] No blank lines allowed before function docstring (found 1) D.py:151:5: D201 [*] No blank lines allowed before function docstring (found 1) | 149 | def trailing_and_leading_space(): -150 | +150 | 151 | """Trailing and leading space.""" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D201 -152 | +152 | 153 | pass | = help: Remove blank line(s) before function docstring @@ -43,10 +42,9 @@ D.py:151:5: D201 [*] No blank lines allowed before function docstring (found 1) D.py:546:5: D201 [*] No blank lines allowed before function docstring (found 1) | 544 | def multiline_leading_space(): -545 | -546 | """Leading space. - | _____^ -547 | | +545 | +546 | / """Leading space. +547 | | 548 | | More content. 549 | | """ | |_______^ D201 @@ -65,14 +63,13 @@ D.py:546:5: D201 [*] No blank lines allowed before function docstring (found 1) D.py:568:5: D201 [*] No blank lines allowed before function docstring (found 1) | 566 | def multiline_trailing_and_leading_space(): -567 | -568 | """Trailing and leading space. - | _____^ -569 | | +567 | +568 | / """Trailing and leading space. +569 | | 570 | | More content. 571 | | """ | |_______^ D201 -572 | +572 | 573 | pass | = help: Remove blank line(s) before function docstring diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D.py.snap index 67b98d7f56727..8852a6a690f66 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D.py:142:5: D202 [*] No blank lines allowed after function docstring (found 1) | @@ -8,7 +7,7 @@ D.py:142:5: D202 [*] No blank lines allowed after function docstring (found 1) 141 | def trailing_space(): 142 | """Leading space.""" | ^^^^^^^^^^^^^^^^^^^^ D202 -143 | +143 | 144 | pass | = help: Remove blank line(s) after function docstring @@ -25,10 +24,10 @@ D.py:142:5: D202 [*] No blank lines allowed after function docstring (found 1) D.py:151:5: D202 [*] No blank lines allowed after function docstring (found 1) | 149 | def trailing_and_leading_space(): -150 | +150 | 151 | """Trailing and leading space.""" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D202 -152 | +152 | 153 | pass | = help: Remove blank line(s) after function docstring @@ -46,13 +45,12 @@ D.py:555:5: D202 [*] No blank lines allowed after function docstring (found 1) | 553 | @expect('D213: Multi-line docstring summary should start at the second line') 554 | def multiline_trailing_space(): -555 | """Leading space. - | _____^ -556 | | +555 | / """Leading space. +556 | | 557 | | More content. 558 | | """ | |_______^ D202 -559 | +559 | 560 | pass | = help: Remove blank line(s) after function docstring @@ -69,14 +67,13 @@ D.py:555:5: D202 [*] No blank lines allowed after function docstring (found 1) D.py:568:5: D202 [*] No blank lines allowed after function docstring (found 1) | 566 | def multiline_trailing_and_leading_space(): -567 | -568 | """Trailing and leading space. - | _____^ -569 | | +567 | +568 | / """Trailing and leading space. +569 | | 570 | | More content. 571 | | """ | |_______^ D202 -572 | +572 | 573 | pass | = help: Remove blank line(s) after function docstring diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D203_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D203_D.py.snap index bdf0d463ff582..741f6b8bb2b2a 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D203_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D203_D.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D.py:161:5: D203 [*] 1 blank line required before class docstring | @@ -41,16 +40,15 @@ D.py:526:5: D203 [*] 1 blank line required before class docstring | 524 | # parameters as functions for Google / Numpy conventions. 525 | class Blah: # noqa: D203,D213 -526 | """A Blah. - | _____^ -527 | | +526 | / """A Blah. +527 | | 528 | | Parameters 529 | | ---------- 530 | | x : int -531 | | +531 | | 532 | | """ | |_______^ D203 -533 | +533 | 534 | def __init__(self, x): | = help: Insert 1 blank line before class docstring diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D205_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D205_D.py.snap index 76004ebc6c494..3c6ca2058018a 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D205_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D205_D.py.snap @@ -1,15 +1,13 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D.py:200:5: D205 1 blank line required between summary line and description | 198 | @expect('D213: Multi-line docstring summary should start at the second line') 199 | def multi_line_zero_separating_blanks(): -200 | """Summary. - | _____^ +200 | / """Summary. 201 | | Description. -202 | | +202 | | 203 | | """ | |_______^ D205 | @@ -19,12 +17,11 @@ D.py:210:5: D205 [*] 1 blank line required between summary line and description | 208 | @expect('D213: Multi-line docstring summary should start at the second line') 209 | def multi_line_two_separating_blanks(): -210 | """Summary. - | _____^ -211 | | -212 | | +210 | / """Summary. +211 | | +212 | | 213 | | Description. -214 | | +214 | | 215 | | """ | |_______^ D205 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D209_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D209_D.py.snap index cc26e3201bcbc..abaf49d7afb2e 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D209_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D209_D.py.snap @@ -1,14 +1,12 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D.py:281:5: D209 [*] Multi-line docstring closing quotes should be on a separate line | 279 | @expect('D213: Multi-line docstring summary should start at the second line') 280 | def asdfljdf24(): -281 | """Summary. - | _____^ -282 | | +281 | / """Summary. +282 | | 283 | | Description.""" | |___________________^ D209 | @@ -29,9 +27,8 @@ D.py:588:5: D209 [*] Multi-line docstring closing quotes should be on a separate | 586 | @expect('D213: Multi-line docstring summary should start at the second line') 587 | def asdfljdjgf24(): -588 | """Summary. - | _____^ -589 | | +588 | / """Summary. +589 | | 590 | | Description. """ | |_____________________^ D209 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D210_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D210_D.py.snap index 554afc5afaf31..a964004890030 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D210_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D210_D.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D.py:288:5: D210 [*] No whitespaces allowed surrounding docstring text | @@ -44,9 +43,8 @@ D.py:299:5: D210 [*] No whitespaces allowed surrounding docstring text | 297 | @expect('D213: Multi-line docstring summary should start at the second line') 298 | def multiline(): -299 | """ Whitespace at the beginning. - | _____^ -300 | | +299 | / """ Whitespace at the beginning. +300 | | 301 | | This is the end. 302 | | """ | |_______^ D210 diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D212_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D212_D.py.snap index d26db14bd0b5e..5e8b8881c2f45 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D212_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D212_D.py.snap @@ -1,13 +1,11 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D.py:129:5: D212 [*] Multi-line docstring summary should start at the first line | 127 | @expect('D212: Multi-line docstring summary should start at the first line') 128 | def asdlkfasd(): -129 | """ - | _____^ +129 | / """ 130 | | Wrong. 131 | | """ | |_______^ D212 @@ -29,9 +27,8 @@ D.py:597:5: D212 [*] Multi-line docstring summary should start at the first line | 595 | @expect('D212: Multi-line docstring summary should start at the first line') 596 | def one_liner(): -597 | """ - | _____^ -598 | | +597 | / """ +598 | | 599 | | Wrong.""" | |_____________^ D212 | @@ -53,9 +50,8 @@ D.py:624:5: D212 [*] Multi-line docstring summary should start at the first line | 622 | @expect('D212: Multi-line docstring summary should start at the first line') 623 | def one_liner(): -624 | """ - | _____^ -625 | | +624 | / """ +625 | | 626 | | "Wrong.""" | |______________^ D212 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D213_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D213_D.py.snap index f0cc9ba885624..66aa330b5a8e2 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D213_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D213_D.py.snap @@ -1,15 +1,13 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D.py:200:5: D213 [*] Multi-line docstring summary should start at the second line | 198 | @expect('D213: Multi-line docstring summary should start at the second line') 199 | def multi_line_zero_separating_blanks(): -200 | """Summary. - | _____^ +200 | / """Summary. 201 | | Description. -202 | | +202 | | 203 | | """ | |_______^ D213 | @@ -30,12 +28,11 @@ D.py:210:5: D213 [*] Multi-line docstring summary should start at the second lin | 208 | @expect('D213: Multi-line docstring summary should start at the second line') 209 | def multi_line_two_separating_blanks(): -210 | """Summary. - | _____^ -211 | | -212 | | +210 | / """Summary. +211 | | +212 | | 213 | | Description. -214 | | +214 | | 215 | | """ | |_______^ D213 | @@ -56,11 +53,10 @@ D.py:220:5: D213 [*] Multi-line docstring summary should start at the second lin | 218 | @expect('D213: Multi-line docstring summary should start at the second line') 219 | def multi_line_one_separating_blanks(): -220 | """Summary. - | _____^ -221 | | +220 | / """Summary. +221 | | 222 | | Description. -223 | | +223 | | 224 | | """ | |_______^ D213 | @@ -81,11 +77,10 @@ D.py:230:5: D213 [*] Multi-line docstring summary should start at the second lin | 228 | @expect('D213: Multi-line docstring summary should start at the second line') 229 | def asdfsdf(): -230 | """Summary. - | _____^ -231 | | +230 | / """Summary. +231 | | 232 | | Description. -233 | | +233 | | 234 | | """ | |_______^ D213 | @@ -106,11 +101,10 @@ D.py:240:5: D213 [*] Multi-line docstring summary should start at the second lin | 238 | @expect('D213: Multi-line docstring summary should start at the second line') 239 | def asdsdfsdffsdf(): -240 | """Summary. - | _____^ -241 | | +240 | / """Summary. +241 | | 242 | | Description. -243 | | +243 | | 244 | | """ | |___^ D213 | @@ -131,11 +125,10 @@ D.py:250:5: D213 [*] Multi-line docstring summary should start at the second lin | 248 | @expect('D213: Multi-line docstring summary should start at the second line') 249 | def asdfsdsdf24(): -250 | """Summary. - | _____^ -251 | | +250 | / """Summary. +251 | | 252 | | Description. -253 | | +253 | | 254 | | """ | |_______^ D213 | @@ -156,11 +149,10 @@ D.py:260:5: D213 [*] Multi-line docstring summary should start at the second lin | 258 | @expect('D213: Multi-line docstring summary should start at the second line') 259 | def asdfsdsdfsdf24(): -260 | """Summary. - | _____^ -261 | | +260 | / """Summary. +261 | | 262 | | Description. -263 | | +263 | | 264 | | """ | |___________^ D213 | @@ -181,11 +173,10 @@ D.py:270:5: D213 [*] Multi-line docstring summary should start at the second lin | 268 | @expect('D213: Multi-line docstring summary should start at the second line') 269 | def asdfsdfsdsdsdfsdf24(): -270 | """Summary. - | _____^ -271 | | +270 | / """Summary. +271 | | 272 | | Description. -273 | | +273 | | 274 | | """ | |_______^ D213 | @@ -206,9 +197,8 @@ D.py:281:5: D213 [*] Multi-line docstring summary should start at the second lin | 279 | @expect('D213: Multi-line docstring summary should start at the second line') 280 | def asdfljdf24(): -281 | """Summary. - | _____^ -282 | | +281 | / """Summary. +282 | | 283 | | Description.""" | |___________________^ D213 | @@ -229,9 +219,8 @@ D.py:299:5: D213 [*] Multi-line docstring summary should start at the second lin | 297 | @expect('D213: Multi-line docstring summary should start at the second line') 298 | def multiline(): -299 | """ Whitespace at the beginning. - | _____^ -300 | | +299 | / """ Whitespace at the beginning. +300 | | 301 | | This is the end. 302 | | """ | |_______^ D213 @@ -253,9 +242,8 @@ D.py:343:5: D213 [*] Multi-line docstring summary should start at the second lin | 341 | @expect('D213: Multi-line docstring summary should start at the second line') 342 | def exceptions_of_D301(): -343 | """Exclude some backslashes from D301. - | _____^ -344 | | +343 | / """Exclude some backslashes from D301. +344 | | 345 | | In particular, line continuations \ 346 | | and unicode literals \u0394 and \N{GREEK CAPITAL LETTER DELTA}. 347 | | They are considered to be intentionally unescaped. @@ -279,9 +267,8 @@ D.py:383:5: D213 [*] Multi-line docstring summary should start at the second lin | 381 | @expect('D213: Multi-line docstring summary should start at the second line') 382 | def new_209(): -383 | """First line. - | _____^ -384 | | +383 | / """First line. +384 | | 385 | | More lines. 386 | | """ | |_______^ D213 @@ -304,11 +291,10 @@ D.py:392:5: D213 [*] Multi-line docstring summary should start at the second lin | 390 | @expect('D213: Multi-line docstring summary should start at the second line') 391 | def old_209(): -392 | """One liner. - | _____^ -393 | | +392 | / """One liner. +393 | | 394 | | Multi-line comments. OK to have extra blank line -395 | | +395 | | 396 | | """ | |_______^ D213 | @@ -331,7 +317,7 @@ D.py:438:37: D213 [*] Multi-line docstring summary should start at the second li 437 | @expect('D213: Multi-line docstring summary should start at the second line') 438 | def docstring_start_in_same_line(): """First Line. | _____________________________________^ -439 | | +439 | | 440 | | Second Line 441 | | """ | |_______^ D213 @@ -353,11 +339,10 @@ D.py:450:5: D213 [*] Multi-line docstring summary should start at the second lin | 448 | @expect('D213: Multi-line docstring summary should start at the second line') 449 | def a_following_valid_function(x=None): -450 | """Check for a bug where the previous function caused an assertion. - | _____^ -451 | | +450 | / """Check for a bug where the previous function caused an assertion. +451 | | 452 | | The assertion was caused in the next function, so this one is necessary. -453 | | +453 | | 454 | | """ | |_______^ D213 | @@ -378,16 +363,15 @@ D.py:526:5: D213 [*] Multi-line docstring summary should start at the second lin | 524 | # parameters as functions for Google / Numpy conventions. 525 | class Blah: # noqa: D203,D213 -526 | """A Blah. - | _____^ -527 | | +526 | / """A Blah. +527 | | 528 | | Parameters 529 | | ---------- 530 | | x : int -531 | | +531 | | 532 | | """ | |_______^ D213 -533 | +533 | 534 | def __init__(self, x): | = help: Insert line break and indentation after opening quotes @@ -406,10 +390,9 @@ D.py:526:5: D213 [*] Multi-line docstring summary should start at the second lin D.py:546:5: D213 [*] Multi-line docstring summary should start at the second line | 544 | def multiline_leading_space(): -545 | -546 | """Leading space. - | _____^ -547 | | +545 | +546 | / """Leading space. +547 | | 548 | | More content. 549 | | """ | |_______^ D213 @@ -431,13 +414,12 @@ D.py:555:5: D213 [*] Multi-line docstring summary should start at the second lin | 553 | @expect('D213: Multi-line docstring summary should start at the second line') 554 | def multiline_trailing_space(): -555 | """Leading space. - | _____^ -556 | | +555 | / """Leading space. +556 | | 557 | | More content. 558 | | """ | |_______^ D213 -559 | +559 | 560 | pass | = help: Insert line break and indentation after opening quotes @@ -456,14 +438,13 @@ D.py:555:5: D213 [*] Multi-line docstring summary should start at the second lin D.py:568:5: D213 [*] Multi-line docstring summary should start at the second line | 566 | def multiline_trailing_and_leading_space(): -567 | -568 | """Trailing and leading space. - | _____^ -569 | | +567 | +568 | / """Trailing and leading space. +569 | | 570 | | More content. 571 | | """ | |_______^ D213 -572 | +572 | 573 | pass | = help: Insert line break and indentation after opening quotes @@ -483,9 +464,8 @@ D.py:588:5: D213 [*] Multi-line docstring summary should start at the second lin | 586 | @expect('D213: Multi-line docstring summary should start at the second line') 587 | def asdfljdjgf24(): -588 | """Summary. - | _____^ -589 | | +588 | / """Summary. +589 | | 590 | | Description. """ | |_____________________^ D213 | @@ -506,9 +486,8 @@ D.py:606:5: D213 [*] Multi-line docstring summary should start at the second lin | 604 | @expect('D212: Multi-line docstring summary should start at the first line') 605 | def one_liner(): -606 | r"""Wrong. - | _____^ -607 | | +606 | / r"""Wrong. +607 | | 608 | | """ | |_______^ D213 | @@ -529,9 +508,8 @@ D.py:615:5: D213 [*] Multi-line docstring summary should start at the second lin | 613 | @expect('D212: Multi-line docstring summary should start at the first line') 614 | def one_liner(): -615 | """Wrong." - | _____^ -616 | | +615 | / """Wrong." +616 | | 617 | | """ | |_______^ D213 | @@ -551,9 +529,8 @@ D.py:615:5: D213 [*] Multi-line docstring summary should start at the second lin D.py:671:5: D213 [*] Multi-line docstring summary should start at the second line | 670 | def retain_extra_whitespace(): -671 | """Summary. - | _____^ -672 | | +671 | / """Summary. +672 | | 673 | | This is overindented 674 | | And so is this, but it we should preserve the extra space on this line relative 675 | | to the one before @@ -576,9 +553,8 @@ D.py:671:5: D213 [*] Multi-line docstring summary should start at the second lin D.py:680:5: D213 [*] Multi-line docstring summary should start at the second line | 679 | def retain_extra_whitespace_multiple(): -680 | """Summary. - | _____^ -681 | | +680 | / """Summary. +681 | | 682 | | This is overindented 683 | | And so is this, but it we should preserve the extra space on this line relative 684 | | to the one before @@ -604,16 +580,15 @@ D.py:680:5: D213 [*] Multi-line docstring summary should start at the second lin D.py:693:5: D213 [*] Multi-line docstring summary should start at the second line | 692 | def retain_extra_whitespace_deeper(): -693 | """Summary. - | _____^ -694 | | +693 | / """Summary. +694 | | 695 | | This is overindented 696 | | And so is this, but it we should preserve the extra space on this line relative 697 | | to the one before 698 | | And the relative indent here should be preserved too 699 | | """ | |_______^ D213 -700 | +700 | 701 | def retain_extra_whitespace_followed_by_same_offset(): | = help: Insert line break and indentation after opening quotes @@ -632,9 +607,8 @@ D.py:693:5: D213 [*] Multi-line docstring summary should start at the second lin D.py:702:5: D213 [*] Multi-line docstring summary should start at the second line | 701 | def retain_extra_whitespace_followed_by_same_offset(): -702 | """Summary. - | _____^ -703 | | +702 | / """Summary. +703 | | 704 | | This is overindented 705 | | And so is this, but it we should preserve the extra space on this line relative 706 | | This is overindented @@ -658,9 +632,8 @@ D.py:702:5: D213 [*] Multi-line docstring summary should start at the second lin D.py:712:5: D213 [*] Multi-line docstring summary should start at the second line | 711 | def retain_extra_whitespace_not_overindented(): -712 | """Summary. - | _____^ -713 | | +712 | / """Summary. +713 | | 714 | | This is not overindented 715 | | This is overindented, but since one line is not overindented this should not raise 716 | | And so is this, but it we should preserve the extra space on this line relative @@ -683,9 +656,8 @@ D.py:712:5: D213 [*] Multi-line docstring summary should start at the second lin D.py:721:5: D213 [*] Multi-line docstring summary should start at the second line | 720 | def inconsistent_indent_byte_size(): -721 | """There's a non-breaking space (2-bytes) after 3 spaces (https://github.com/astral-sh/ruff/issues/9080). - | _____^ -722 | | +721 | / """There's a non-breaking space (2-bytes) after 3 spaces (https://github.com/astral-sh/ruff/issues/9080). +722 | | 723 | |     Returns: 724 | | """ | |_______^ D213 diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D300_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D300_D.py.snap index 94ec066d964a4..23ef16355041c 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D300_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D300_D.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D.py:307:5: D300 [*] Use triple double quotes `"""` | @@ -100,11 +99,10 @@ D.py:328:5: D300 [*] Use triple double quotes `"""` D.py:645:5: D300 [*] Use triple double quotes `"""` | 644 | def single_line_docstring_with_an_escaped_backslash(): -645 | "\ - | _____^ +645 | / "\ 646 | | " | |_____^ D300 -647 | +647 | 648 | class StatementOnSameLineAsDocstring: | = help: Convert to triple double quotes @@ -182,8 +180,7 @@ D.py:658:5: D300 [*] Use triple double quotes `"""` D.py:664:5: D300 [*] Use triple double quotes `"""` | 663 | def newline_after_closing_quote(self): -664 | "We enforce a newline after the closing quote for a multi-line docstring \ - | _____^ +664 | / "We enforce a newline after the closing quote for a multi-line docstring \ 665 | | but continuations shouldn't be considered multi-line" | |_________________________________________________________^ D300 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D301.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D301.py.snap index e30bee97a5ef4..ffd336a556550 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D301.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D301.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D301.py:2:5: D301 [*] Use `r"""` if any backslashes in a docstring | @@ -29,8 +28,7 @@ D301.py:37:5: D301 Use `r"""` if any backslashes in a docstring D301.py:93:5: D301 [*] Use `r"""` if any backslashes in a docstring | 92 | def should_add_raw_for_single_double_quote_escape(): -93 | """ - | _____^ +93 | / """ 94 | | This is single quote escape \". 95 | | """ | |_______^ D301 @@ -50,8 +48,7 @@ D301.py:93:5: D301 [*] Use `r"""` if any backslashes in a docstring D301.py:99:5: D301 [*] Use `r"""` if any backslashes in a docstring | 98 | def should_add_raw_for_single_single_quote_escape(): - 99 | ''' - | _____^ + 99 | / ''' 100 | | This is single quote escape \'. 101 | | ''' | |_______^ D301 diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D.py.snap index e8ba4ec299d82..f61fcc94b928f 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D.py:355:5: D400 [*] First line should end with a period | @@ -245,9 +244,8 @@ D.py:615:5: D400 [*] First line should end with a period | 613 | @expect('D212: Multi-line docstring summary should start at the first line') 614 | def one_liner(): -615 | """Wrong." - | _____^ -616 | | +615 | / """Wrong." +616 | | 617 | | """ | |_______^ D400 | @@ -267,7 +265,7 @@ D.py:639:17: D400 [*] First line should end with a period | 639 | class SameLine: """This is a docstring on the same line""" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 -640 | +640 | 641 | def same_line(): """This is a docstring on the same line""" | = help: Add period @@ -285,7 +283,7 @@ D.py:639:17: D400 [*] First line should end with a period D.py:641:18: D400 [*] First line should end with a period | 639 | class SameLine: """This is a docstring on the same line""" -640 | +640 | 641 | def same_line(): """This is a docstring on the same line""" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 | @@ -304,8 +302,7 @@ D.py:641:18: D400 [*] First line should end with a period D.py:664:5: D400 [*] First line should end with a period | 663 | def newline_after_closing_quote(self): -664 | "We enforce a newline after the closing quote for a multi-line docstring \ - | _____^ +664 | / "We enforce a newline after the closing quote for a multi-line docstring \ 665 | | but continuations shouldn't be considered multi-line" | |_________________________________________________________^ D400 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D400.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D400.py.snap index 0214242d6e149..752bf81900d2e 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D400.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D400.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D400.py:2:5: D400 [*] First line should end with a period | @@ -41,8 +40,7 @@ D400.py:7:5: D400 [*] First line should end with a period D400.py:12:5: D400 [*] First line should end with a period | 11 | def f(): -12 | """ - | _____^ +12 | / """ 13 | | Here's a line without a period, 14 | | but here's the next line 15 | | """ @@ -83,8 +81,7 @@ D400.py:20:5: D400 [*] First line should end with a period D400.py:25:5: D400 [*] First line should end with a period | 24 | def f(): -25 | """ - | _____^ +25 | / """ 26 | | Here's a line without a period, 27 | | but here's the next line""" | |_______________________________^ D400 @@ -105,8 +102,7 @@ D400.py:25:5: D400 [*] First line should end with a period D400.py:32:5: D400 [*] First line should end with a period | 31 | def f(): -32 | """ - | _____^ +32 | / """ 33 | | Here's a line without a period, 34 | | but here's the next line with trailing space """ | |____________________________________________________^ D400 @@ -165,8 +161,7 @@ D400.py:44:5: D400 [*] First line should end with a period D400.py:49:5: D400 [*] First line should end with a period | 48 | def f(): -49 | r""" - | _____^ +49 | / r""" 50 | | Here's a line without a period, 51 | | but here's the next line 52 | | """ @@ -207,8 +202,7 @@ D400.py:57:5: D400 [*] First line should end with a period D400.py:62:5: D400 [*] First line should end with a period | 61 | def f(): -62 | r""" - | _____^ +62 | / r""" 63 | | Here's a line without a period, 64 | | but here's the next line""" | |_______________________________^ D400 @@ -229,8 +223,7 @@ D400.py:62:5: D400 [*] First line should end with a period D400.py:69:5: D400 [*] First line should end with a period | 68 | def f(): -69 | r""" - | _____^ +69 | / r""" 70 | | Here's a line without a period, 71 | | but here's the next line with trailing space """ | |____________________________________________________^ D400 @@ -251,11 +244,10 @@ D400.py:69:5: D400 [*] First line should end with a period D400.py:97:5: D400 [*] First line should end with a period | 96 | def f(): - 97 | """ - | _____^ + 97 | / """ 98 | | My example 99 | | ========== -100 | | +100 | | 101 | | My example explanation 102 | | """ | |_______^ D400 diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D401_D401.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D401_D401.py.snap index c0e59321e731f..d649ee60dc961 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D401_D401.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D401_D401.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D401.py:10:5: D401 First line of docstring should be in imperative mood: "Returns foo." | @@ -19,11 +18,10 @@ D401.py:14:5: D401 First line of docstring should be in imperative mood: "Constr D401.py:18:5: D401 First line of docstring should be in imperative mood: "Constructor for a boa." | 17 | def bad_sdgfsdg23245777(): -18 | """ - | _____^ -19 | | +18 | / """ +19 | | 20 | | Constructor for a boa. -21 | | +21 | | 22 | | """ | |_______^ D401 | @@ -33,7 +31,7 @@ D401.py:26:5: D401 First line of docstring should be in imperative mood: "Runs s 25 | def bad_run_something(): 26 | """Runs something""" | ^^^^^^^^^^^^^^^^^^^^ D401 -27 | +27 | 28 | def bad_nested(): | @@ -42,15 +40,14 @@ D401.py:29:9: D401 First line of docstring should be in imperative mood: "Runs o 28 | def bad_nested(): 29 | """Runs other things, nested""" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D401 -30 | +30 | 31 | bad_nested() | D401.py:35:5: D401 First line of docstring should be in imperative mood: "Writes a logical line that" | 34 | def multi_line(): -35 | """Writes a logical line that - | _____^ +35 | / """Writes a logical line that 36 | | extends to two physical lines. 37 | | """ | |_______^ D401 @@ -61,6 +58,6 @@ D401.py:74:9: D401 First line of docstring should be in imperative mood: "This m 73 | def bad_method(self): 74 | """This method docstring should be written in imperative mood.""" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D401 -75 | +75 | 76 | @property | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D403_D403.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D403_D403.py.snap index b365fb6b4cfe2..201b1f68a55d5 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D403_D403.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D403_D403.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D403.py:2:5: D403 [*] First word of the docstring should be capitalized: `this` -> `This` | 1 | def bad_function(): 2 | """this docstring is not capitalized""" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D403 -3 | +3 | 4 | def good_function(): | = help: Capitalize `this` to `This` @@ -25,7 +24,7 @@ D403.py:30:5: D403 [*] First word of the docstring should be capitalized: `singl 29 | def single_word(): 30 | """singleword.""" | ^^^^^^^^^^^^^^^^^ D403 -31 | +31 | 32 | def single_word_no_dot(): | = help: Capitalize `singleword` to `Singleword` @@ -45,7 +44,7 @@ D403.py:33:5: D403 [*] First word of the docstring should be capitalized: `singl 32 | def single_word_no_dot(): 33 | """singleword""" | ^^^^^^^^^^^^^^^^ D403 -34 | +34 | 35 | def first_word_lots_of_whitespace(): | = help: Capitalize `singleword` to `Singleword` @@ -63,17 +62,16 @@ D403.py:33:5: D403 [*] First word of the docstring should be capitalized: `singl D403.py:36:5: D403 [*] First word of the docstring should be capitalized: `here` -> `Here` | 35 | def first_word_lots_of_whitespace(): -36 | """ - | _____^ -37 | | -38 | | -39 | | +36 | / """ +37 | | +38 | | +39 | | 40 | | here is the start of my docstring! -41 | | +41 | | 42 | | What do you think? 43 | | """ | |_______^ D403 -44 | +44 | 45 | def single_word_newline(): | = help: Capitalize `here` to `Here` @@ -91,12 +89,11 @@ D403.py:36:5: D403 [*] First word of the docstring should be capitalized: `here` D403.py:46:5: D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` | 45 | def single_word_newline(): -46 | """singleword - | _____^ -47 | | +46 | / """singleword +47 | | 48 | | """ | |_______^ D403 -49 | +49 | 50 | def single_word_dot_newline(): | = help: Capitalize `singleword` to `Singleword` @@ -114,12 +111,11 @@ D403.py:46:5: D403 [*] First word of the docstring should be capitalized: `singl D403.py:51:5: D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` | 50 | def single_word_dot_newline(): -51 | """singleword. - | _____^ -52 | | +51 | / """singleword. +52 | | 53 | | """ | |_______^ D403 -54 | +54 | 55 | def single_word_second_line(): | = help: Capitalize `singleword` to `Singleword` @@ -137,12 +133,11 @@ D403.py:51:5: D403 [*] First word of the docstring should be capitalized: `singl D403.py:56:5: D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` | 55 | def single_word_second_line(): -56 | """ - | _____^ +56 | / """ 57 | | singleword 58 | | """ | |_______^ D403 -59 | +59 | 60 | def single_word_dot_second_line(): | = help: Capitalize `singleword` to `Singleword` @@ -160,12 +155,11 @@ D403.py:56:5: D403 [*] First word of the docstring should be capitalized: `singl D403.py:61:5: D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` | 60 | def single_word_dot_second_line(): -61 | """ - | _____^ +61 | / """ 62 | | singleword. 63 | | """ | |_______^ D403 -64 | +64 | 65 | def single_word_then_more_text(): | = help: Capitalize `singleword` to `Singleword` @@ -183,13 +177,12 @@ D403.py:61:5: D403 [*] First word of the docstring should be capitalized: `singl D403.py:66:5: D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` | 65 | def single_word_then_more_text(): -66 | """singleword - | _____^ -67 | | +66 | / """singleword +67 | | 68 | | This is more text. 69 | | """ | |_______^ D403 -70 | +70 | 71 | def single_word_dot_then_more_text(): | = help: Capitalize `singleword` to `Singleword` @@ -207,13 +200,12 @@ D403.py:66:5: D403 [*] First word of the docstring should be capitalized: `singl D403.py:72:5: D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` | 71 | def single_word_dot_then_more_text(): -72 | """singleword. - | _____^ -73 | | +72 | / """singleword. +73 | | 74 | | This is more text. 75 | | """ | |_______^ D403 -76 | +76 | 77 | def single_word_second_line_then_more_text(): | = help: Capitalize `singleword` to `Singleword` @@ -231,14 +223,13 @@ D403.py:72:5: D403 [*] First word of the docstring should be capitalized: `singl D403.py:78:5: D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` | 77 | def single_word_second_line_then_more_text(): -78 | """ - | _____^ +78 | / """ 79 | | singleword -80 | | +80 | | 81 | | This is more text. 82 | | """ | |_______^ D403 -83 | +83 | 84 | def single_word_dot_second_line_then_more_text(): | = help: Capitalize `singleword` to `Singleword` @@ -256,10 +247,9 @@ D403.py:78:5: D403 [*] First word of the docstring should be capitalized: `singl D403.py:85:5: D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` | 84 | def single_word_dot_second_line_then_more_text(): -85 | """ - | _____^ +85 | / """ 86 | | singleword. -87 | | +87 | | 88 | | This is more text. 89 | | """ | |_______^ D403 diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D415_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D415_D.py.snap index 55cee7a07f865..83922317dc2cd 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D415_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D415_D.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D.py:355:5: D415 [*] First line should end with a period, question mark, or exclamation point | @@ -237,9 +236,8 @@ D.py:615:5: D415 [*] First line should end with a period, question mark, or excl | 613 | @expect('D212: Multi-line docstring summary should start at the first line') 614 | def one_liner(): -615 | """Wrong." - | _____^ -616 | | +615 | / """Wrong." +616 | | 617 | | """ | |_______^ D415 | @@ -259,7 +257,7 @@ D.py:639:17: D415 [*] First line should end with a period, question mark, or exc | 639 | class SameLine: """This is a docstring on the same line""" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D415 -640 | +640 | 641 | def same_line(): """This is a docstring on the same line""" | = help: Add closing punctuation @@ -277,7 +275,7 @@ D.py:639:17: D415 [*] First line should end with a period, question mark, or exc D.py:641:18: D415 [*] First line should end with a period, question mark, or exclamation point | 639 | class SameLine: """This is a docstring on the same line""" -640 | +640 | 641 | def same_line(): """This is a docstring on the same line""" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D415 | @@ -296,8 +294,7 @@ D.py:641:18: D415 [*] First line should end with a period, question mark, or exc D.py:664:5: D415 [*] First line should end with a period, question mark, or exclamation point | 663 | def newline_after_closing_quote(self): -664 | "We enforce a newline after the closing quote for a multi-line docstring \ - | _____^ +664 | / "We enforce a newline after the closing quote for a multi-line docstring \ 665 | | but continuations shouldn't be considered multi-line" | |_________________________________________________________^ D415 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d209_d400.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d209_d400.snap index 23f5c03653bdf..00b6e1887d546 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d209_d400.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d209_d400.snap @@ -1,12 +1,10 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D209_D400.py:2:5: D209 [*] Multi-line docstring closing quotes should be on a separate line | 1 | def lorem(): -2 | """lorem ipsum dolor sit amet consectetur adipiscing elit - | _____^ +2 | / """lorem ipsum dolor sit amet consectetur adipiscing elit 3 | | sed do eiusmod tempor incididunt ut labore et dolore magna aliqua""" | |________________________________________________________________________^ D209 | @@ -22,8 +20,7 @@ D209_D400.py:2:5: D209 [*] Multi-line docstring closing quotes should be on a se D209_D400.py:2:5: D400 [*] First line should end with a period | 1 | def lorem(): -2 | """lorem ipsum dolor sit amet consectetur adipiscing elit - | _____^ +2 | / """lorem ipsum dolor sit amet consectetur adipiscing elit 3 | | sed do eiusmod tempor incididunt ut labore et dolore magna aliqua""" | |________________________________________________________________________^ D400 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1142_await_outside_async.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1142_await_outside_async.py.snap index ca050da3e0ef1..9e61d1d6f32dd 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1142_await_outside_async.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1142_await_outside_async.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- await_outside_async.py:15:11: PLE1142 `await` should be used within an async function | @@ -20,8 +19,7 @@ await_outside_async.py:29:9: PLE1142 `await` should be used within an async func await_outside_async.py:38:5: PLE1142 `await` should be used within an async function | 37 | def async_for_loop(): -38 | async for x in foo(): - | _____^ +38 | / async for x in foo(): 39 | | pass | |____________^ PLE1142 | @@ -29,8 +27,7 @@ await_outside_async.py:38:5: PLE1142 `await` should be used within an async func await_outside_async.py:43:5: PLE1142 `await` should be used within an async function | 42 | def async_with(): -43 | async with foo(): - | _____^ +43 | / async with foo(): 44 | | pass | |____________^ PLE1142 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1310_bad_str_strip_call.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1310_bad_str_strip_call.py.snap index b3c17c904180d..889fca29d760d 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1310_bad_str_strip_call.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1310_bad_str_strip_call.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- bad_str_strip_call.py:2:21: PLE1310 String `strip` call contains duplicate characters | 1 | # PLE1310 2 | "Hello World".strip("Hello") | ^^^^^^^ PLE1310 -3 | +3 | 4 | # PLE1310 | @@ -16,7 +15,7 @@ bad_str_strip_call.py:5:21: PLE1310 String `strip` call contains duplicate chara 4 | # PLE1310 5 | "Hello World".strip("Hello") | ^^^^^^^ PLE1310 -6 | +6 | 7 | # PLE1310 | @@ -25,7 +24,7 @@ bad_str_strip_call.py:8:21: PLE1310 String `strip` call contains duplicate chara 7 | # PLE1310 8 | "Hello World".strip(u"Hello") | ^^^^^^^^ PLE1310 - 9 | + 9 | 10 | # PLE1310 | @@ -34,7 +33,7 @@ bad_str_strip_call.py:11:21: PLE1310 String `strip` call contains duplicate char 10 | # PLE1310 11 | "Hello World".strip(r"Hello") | ^^^^^^^^ PLE1310 -12 | +12 | 13 | # PLE1310 | @@ -43,7 +42,7 @@ bad_str_strip_call.py:14:21: PLE1310 String `strip` call contains duplicate char 13 | # PLE1310 14 | "Hello World".strip("Hello\t") | ^^^^^^^^^ PLE1310 -15 | +15 | 16 | # PLE1310 | @@ -52,7 +51,7 @@ bad_str_strip_call.py:17:21: PLE1310 String `strip` call contains duplicate char 16 | # PLE1310 17 | "Hello World".strip(r"Hello\t") | ^^^^^^^^^^ PLE1310 -18 | +18 | 19 | # PLE1310 | @@ -61,7 +60,7 @@ bad_str_strip_call.py:20:21: PLE1310 String `strip` call contains duplicate char 19 | # PLE1310 20 | "Hello World".strip("Hello\\") | ^^^^^^^^^ PLE1310 -21 | +21 | 22 | # PLE1310 | @@ -70,7 +69,7 @@ bad_str_strip_call.py:23:21: PLE1310 String `strip` call contains duplicate char 22 | # PLE1310 23 | "Hello World".strip(r"Hello\\") | ^^^^^^^^^^ PLE1310 -24 | +24 | 25 | # PLE1310 | @@ -79,7 +78,7 @@ bad_str_strip_call.py:26:21: PLE1310 String `strip` call contains duplicate char 25 | # PLE1310 26 | "Hello World".strip("🤣🤣🤣🤣🙃👀😀") | ^^^^^^^^^^^^^^^^ PLE1310 -27 | +27 | 28 | # PLE1310 | @@ -87,8 +86,7 @@ bad_str_strip_call.py:30:5: PLE1310 String `strip` call contains duplicate chara | 28 | # PLE1310 29 | "Hello World".strip( -30 | """ - | _____^ +30 | / """ 31 | | there are a lot of characters to strip 32 | | """ | |___^ PLE1310 @@ -103,7 +101,7 @@ bad_str_strip_call.py:36:21: PLE1310 String `strip` call contains duplicate char 37 | | "string of characters to strip " \ 38 | | "please?") | |_____________________________^ PLE1310 -39 | +39 | 40 | # PLE1310 | @@ -111,8 +109,7 @@ bad_str_strip_call.py:42:5: PLE1310 String `strip` call contains duplicate chara | 40 | # PLE1310 41 | "Hello World".strip( -42 | "can we get a long " - | _____^ +42 | / "can we get a long " 43 | | "string of characters to strip " 44 | | "please?" | |_____________^ PLE1310 @@ -123,8 +120,7 @@ bad_str_strip_call.py:49:5: PLE1310 String `strip` call contains duplicate chara | 47 | # PLE1310 48 | "Hello World".strip( -49 | "can \t we get a long" - | _____^ +49 | / "can \t we get a long" 50 | | "string \t of characters to strip" 51 | | "please?" | |_____________^ PLE1310 @@ -136,7 +132,7 @@ bad_str_strip_call.py:61:11: PLE1310 String `strip` call contains duplicate char 60 | # PLE1310 61 | u''.strip('http://') | ^^^^^^^^^ PLE1310 -62 | +62 | 63 | # PLE1310 | @@ -145,7 +141,7 @@ bad_str_strip_call.py:64:12: PLE1310 String `lstrip` call contains duplicate cha 63 | # PLE1310 64 | u''.lstrip('http://') | ^^^^^^^^^ PLE1310 -65 | +65 | 66 | # PLE1310 | @@ -154,6 +150,6 @@ bad_str_strip_call.py:67:12: PLE1310 String `rstrip` call contains duplicate cha 66 | # PLE1310 67 | b''.rstrip('http://') | ^^^^^^^^^ PLE1310 -68 | +68 | 69 | # OK | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1702_too_many_nested_blocks.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1702_too_many_nested_blocks.py.snap index f98ba2c778895..5897b38a4bbcb 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1702_too_many_nested_blocks.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1702_too_many_nested_blocks.py.snap @@ -1,12 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- too_many_nested_blocks.py:2:5: PLR1702 Too many nested blocks (6 > 5) | 1 | def correct_fruits(fruits) -> bool: - 2 | if len(fruits) > 1: # PLR1702 - | _____^ + 2 | / if len(fruits) > 1: # PLR1702 3 | | if "apple" in fruits: 4 | | if "orange" in fruits: 5 | | count = fruits["orange"] diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1716_boolean_chained_comparison.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1716_boolean_chained_comparison.py.snap index f18b102153e90..649554548fadd 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1716_boolean_chained_comparison.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1716_boolean_chained_comparison.py.snap @@ -349,7 +349,7 @@ boolean_chained_comparison.py:127:4: PLR1716 [*] Contains chained boolean compar 126 | (a < b) and (b < c) 127 | (((a < b))) and (b < c) | ^^^^^^^^^^^^^^^^^^^ PLR1716 -128 | +128 | 129 | (a 10: # [min-instead-of-if] | = help: Replace with `value = max(value, value2)` @@ -73,11 +72,11 @@ if_stmt_min_max.py:14:1: PLR1730 [*] Replace `if` statement with `value = max(va if_stmt_min_max.py:17:1: PLR1730 [*] Replace `if` statement with `value = min(value, 10)` | 15 | value = value2 -16 | +16 | 17 | / if value > 10: # [min-instead-of-if] 18 | | value = 10 | |______________^ PLR1730 -19 | +19 | 20 | if value >= 10: # [min-instead-of-if] | = help: Replace with `value = min(value, 10)` @@ -96,11 +95,11 @@ if_stmt_min_max.py:17:1: PLR1730 [*] Replace `if` statement with `value = min(va if_stmt_min_max.py:20:1: PLR1730 [*] Replace `if` statement with `value = min(10, value)` | 18 | value = 10 -19 | +19 | 20 | / if value >= 10: # [min-instead-of-if] 21 | | value = 10 | |______________^ PLR1730 -22 | +22 | 23 | if value > value2: # [min-instead-of-if] | = help: Replace with `value = min(10, value)` @@ -119,7 +118,7 @@ if_stmt_min_max.py:20:1: PLR1730 [*] Replace `if` statement with `value = min(10 if_stmt_min_max.py:23:1: PLR1730 [*] Replace `if` statement with `value = min(value, value2)` | 21 | value = 10 -22 | +22 | 23 | / if value > value2: # [min-instead-of-if] 24 | | value = value2 | |__________________^ PLR1730 @@ -143,7 +142,7 @@ if_stmt_min_max.py:33:1: PLR1730 [*] Replace `if` statement with `A1.value = max 33 | / if A1.value < 10: # [max-instead-of-if] 34 | | A1.value = 10 | |_________________^ PLR1730 -35 | +35 | 36 | if A1.value > 10: # [min-instead-of-if] | = help: Replace with `A1.value = max(A1.value, 10)` @@ -162,7 +161,7 @@ if_stmt_min_max.py:33:1: PLR1730 [*] Replace `if` statement with `A1.value = max if_stmt_min_max.py:36:1: PLR1730 [*] Replace `if` statement with `A1.value = min(A1.value, 10)` | 34 | A1.value = 10 -35 | +35 | 36 | / if A1.value > 10: # [min-instead-of-if] 37 | | A1.value = 10 | |_________________^ PLR1730 @@ -183,11 +182,11 @@ if_stmt_min_max.py:36:1: PLR1730 [*] Replace `if` statement with `A1.value = min if_stmt_min_max.py:60:1: PLR1730 [*] Replace `if` statement with `A2 = max(A2, A1)` | 58 | A2 = AA(3) -59 | +59 | 60 | / if A2 < A1: # [max-instead-of-if] 61 | | A2 = A1 | |___________^ PLR1730 -62 | +62 | 63 | if A2 <= A1: # [max-instead-of-if] | = help: Replace with `A2 = max(A2, A1)` @@ -206,11 +205,11 @@ if_stmt_min_max.py:60:1: PLR1730 [*] Replace `if` statement with `A2 = max(A2, A if_stmt_min_max.py:63:1: PLR1730 [*] Replace `if` statement with `A2 = max(A1, A2)` | 61 | A2 = A1 -62 | +62 | 63 | / if A2 <= A1: # [max-instead-of-if] 64 | | A2 = A1 | |___________^ PLR1730 -65 | +65 | 66 | if A2 > A1: # [min-instead-of-if] | = help: Replace with `A2 = max(A1, A2)` @@ -229,11 +228,11 @@ if_stmt_min_max.py:63:1: PLR1730 [*] Replace `if` statement with `A2 = max(A1, A if_stmt_min_max.py:66:1: PLR1730 [*] Replace `if` statement with `A2 = min(A2, A1)` | 64 | A2 = A1 -65 | +65 | 66 | / if A2 > A1: # [min-instead-of-if] 67 | | A2 = A1 | |___________^ PLR1730 -68 | +68 | 69 | if A2 >= A1: # [min-instead-of-if] | = help: Replace with `A2 = min(A2, A1)` @@ -252,11 +251,11 @@ if_stmt_min_max.py:66:1: PLR1730 [*] Replace `if` statement with `A2 = min(A2, A if_stmt_min_max.py:69:1: PLR1730 [*] Replace `if` statement with `A2 = min(A1, A2)` | 67 | A2 = A1 -68 | +68 | 69 | / if A2 >= A1: # [min-instead-of-if] 70 | | A2 = A1 | |___________^ PLR1730 -71 | +71 | 72 | # Negative | = help: Replace with `A2 = min(A1, A2)` @@ -281,7 +280,7 @@ if_stmt_min_max.py:132:1: PLR1730 [*] Replace `if` statement with `min` call 135 | | attr 136 | | ) = 3 | |_________^ PLR1730 -137 | +137 | 138 | class Foo: | = help: Replace with `min` call @@ -304,8 +303,7 @@ if_stmt_min_max.py:132:1: PLR1730 [*] Replace `if` statement with `min` call if_stmt_min_max.py:143:9: PLR1730 [*] Replace `if` statement with `self._min = min(value, self._min)` | 142 | def foo(self, value) -> None: -143 | if value < self._min: - | _________^ +143 | / if value < self._min: 144 | | self._min = value | |_____________________________^ PLR1730 145 | if value > self._max: @@ -328,11 +326,10 @@ if_stmt_min_max.py:145:9: PLR1730 [*] Replace `if` statement with `self._max = m | 143 | if value < self._min: 144 | self._min = value -145 | if value > self._max: - | _________^ +145 | / if value > self._max: 146 | | self._max = value | |_____________________________^ PLR1730 -147 | +147 | 148 | if self._min < value: | = help: Replace with `self._max = max(value, self._max)` @@ -351,9 +348,8 @@ if_stmt_min_max.py:145:9: PLR1730 [*] Replace `if` statement with `self._max = m if_stmt_min_max.py:148:9: PLR1730 [*] Replace `if` statement with `self._min = max(self._min, value)` | 146 | self._max = value -147 | -148 | if self._min < value: - | _________^ +147 | +148 | / if self._min < value: 149 | | self._min = value | |_____________________________^ PLR1730 150 | if self._max > value: @@ -376,11 +372,10 @@ if_stmt_min_max.py:150:9: PLR1730 [*] Replace `if` statement with `self._max = m | 148 | if self._min < value: 149 | self._min = value -150 | if self._max > value: - | _________^ +150 | / if self._max > value: 151 | | self._max = value | |_____________________________^ PLR1730 -152 | +152 | 153 | if value <= self._min: | = help: Replace with `self._max = min(self._max, value)` @@ -399,9 +394,8 @@ if_stmt_min_max.py:150:9: PLR1730 [*] Replace `if` statement with `self._max = m if_stmt_min_max.py:153:9: PLR1730 [*] Replace `if` statement with `self._min = min(self._min, value)` | 151 | self._max = value -152 | -153 | if value <= self._min: - | _________^ +152 | +153 | / if value <= self._min: 154 | | self._min = value | |_____________________________^ PLR1730 155 | if value >= self._max: @@ -424,11 +418,10 @@ if_stmt_min_max.py:155:9: PLR1730 [*] Replace `if` statement with `self._max = m | 153 | if value <= self._min: 154 | self._min = value -155 | if value >= self._max: - | _________^ +155 | / if value >= self._max: 156 | | self._max = value | |_____________________________^ PLR1730 -157 | +157 | 158 | if self._min <= value: | = help: Replace with `self._max = max(self._max, value)` @@ -447,9 +440,8 @@ if_stmt_min_max.py:155:9: PLR1730 [*] Replace `if` statement with `self._max = m if_stmt_min_max.py:158:9: PLR1730 [*] Replace `if` statement with `self._min = max(value, self._min)` | 156 | self._max = value -157 | -158 | if self._min <= value: - | _________^ +157 | +158 | / if self._min <= value: 159 | | self._min = value | |_____________________________^ PLR1730 160 | if self._max >= value: @@ -471,8 +463,7 @@ if_stmt_min_max.py:160:9: PLR1730 [*] Replace `if` statement with `self._max = m | 158 | if self._min <= value: 159 | self._min = value -160 | if self._max >= value: - | _________^ +160 | / if self._max >= value: 161 | | self._max = value | |_____________________________^ PLR1730 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR5501_collapsible_else_if.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR5501_collapsible_else_if.py.snap index 0ac4f5d772454..44b4747fc265b 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR5501_collapsible_else_if.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR5501_collapsible_else_if.py.snap @@ -1,13 +1,11 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- collapsible_else_if.py:37:5: PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation | 35 | if 1: 36 | pass -37 | else: - | _____^ +37 | / else: 38 | | if 2: | |________^ PLR5501 39 | pass @@ -31,8 +29,7 @@ collapsible_else_if.py:45:5: PLR5501 [*] Use `elif` instead of `else` then `if`, | 43 | if 1: 44 | pass -45 | else: - | _____^ +45 | / else: 46 | | if 2: | |________^ PLR5501 47 | pass @@ -60,8 +57,7 @@ collapsible_else_if.py:55:5: PLR5501 [*] Use `elif` instead of `else` then `if`, | 53 | if 1: 54 | pass -55 | else: - | _____^ +55 | / else: 56 | | # inner comment 57 | | if 2: | |________^ PLR5501 @@ -92,8 +88,7 @@ collapsible_else_if.py:69:5: PLR5501 [*] Use `elif` instead of `else` then `if`, | 67 | elif True: 68 | print(2) -69 | else: - | _____^ +69 | / else: 70 | | if True: | |________^ PLR5501 71 | print(3) @@ -121,8 +116,7 @@ collapsible_else_if.py:79:5: PLR5501 [*] Use `elif` instead of `else` then `if`, | 77 | if 1: 78 | pass -79 | else: - | _____^ +79 | / else: 80 | | if 2: pass | |________^ PLR5501 81 | else: pass @@ -146,8 +140,7 @@ collapsible_else_if.py:87:5: PLR5501 [*] Use `elif` instead of `else` then `if`, | 85 | if 1: 86 | pass -87 | else: - | _____^ +87 | / else: 88 | | if 2: pass | |________^ PLR5501 89 | else: @@ -173,8 +166,7 @@ collapsible_else_if.py:96:5: PLR5501 [*] Use `elif` instead of `else` then `if`, | 94 | if 1: 95 | pass -96 | else: - | _____^ +96 | / else: 97 | | if 2: | |________^ PLR5501 98 | pass @@ -201,8 +193,7 @@ collapsible_else_if.py:105:5: PLR5501 [*] Use `elif` instead of `else` then `if` | 103 | if 1: 104 | pass -105 | else: - | _____^ +105 | / else: 106 | | # inner comment which happens 107 | | # to be longer than one line 108 | | if 2: @@ -236,8 +227,7 @@ collapsible_else_if.py:117:5: PLR5501 [*] Use `elif` instead of `else` then `if` | 115 | if 1: 116 | pass -117 | else: - | _____^ +117 | / else: 118 | | # inner comment which happens to be overly indented 119 | | if 2: | |________^ PLR5501 @@ -268,8 +258,7 @@ collapsible_else_if.py:128:5: PLR5501 [*] Use `elif` instead of `else` then `if` | 126 | if 1: 127 | pass -128 | else: - | _____^ +128 | / else: 129 | | # inner comment which happens to be under indented 130 | | if 2: | |________^ PLR5501 @@ -300,8 +289,7 @@ collapsible_else_if.py:139:5: PLR5501 [*] Use `elif` instead of `else` then `if` | 137 | if 1: 138 | pass -139 | else: - | _____^ +139 | / else: 140 | | # inner comment which has mixed 141 | | # indentation levels 142 | | # which is pretty weird diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0101_unreachable.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0101_unreachable.py.snap index 201782bab9e57..0a506970228b0 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0101_unreachable.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0101_unreachable.py.snap @@ -7,7 +7,7 @@ unreachable.py:3:5: PLW0101 Unreachable code in `after_return` 2 | return "reachable" 3 | return "unreachable" | ^^^^^^^^^^^^^^^^^^^^ PLW0101 -4 | +4 | 5 | async def also_works_on_async_functions(): | @@ -17,7 +17,7 @@ unreachable.py:7:5: PLW0101 Unreachable code in `also_works_on_async_functions` 6 | return "reachable" 7 | return "unreachable" | ^^^^^^^^^^^^^^^^^^^^ PLW0101 -8 | +8 | 9 | def if_always_true(): | @@ -27,7 +27,7 @@ unreachable.py:12:5: PLW0101 Unreachable code in `if_always_true` 11 | return "reachable" 12 | return "unreachable" | ^^^^^^^^^^^^^^^^^^^^ PLW0101 -13 | +13 | 14 | def if_always_false(): | @@ -44,8 +44,7 @@ unreachable.py:21:9: PLW0101 Unreachable code in `if_elif_always_false` | 19 | def if_elif_always_false(): 20 | if False: -21 | return "unreachable" - | _________^ +21 | / return "unreachable" 22 | | elif False: 23 | | return "also unreachable" | |_________________________________^ PLW0101 @@ -68,7 +67,7 @@ unreachable.py:31:5: PLW0101 Unreachable code in `if_elif_always_true` 30 | return "reachable" 31 | return "also unreachable" | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0101 -32 | +32 | 33 | def ends_with_if(): | @@ -88,7 +87,7 @@ unreachable.py:42:5: PLW0101 Unreachable code in `infinite_loop` 41 | continue 42 | return "unreachable" | ^^^^^^^^^^^^^^^^^^^^ PLW0101 -43 | +43 | 44 | ''' TODO: we could determine these, but we don't yet. | @@ -98,7 +97,7 @@ unreachable.py:75:5: PLW0101 Unreachable code in `match_wildcard` 74 | return "reachable" 75 | return "unreachable" | ^^^^^^^^^^^^^^^^^^^^ PLW0101 -76 | +76 | 77 | def match_case_and_wildcard(status): | @@ -108,7 +107,7 @@ unreachable.py:83:5: PLW0101 Unreachable code in `match_case_and_wildcard` 82 | return "reachable" 83 | return "unreachable" | ^^^^^^^^^^^^^^^^^^^^ PLW0101 -84 | +84 | 85 | def raise_exception(): | @@ -118,7 +117,7 @@ unreachable.py:87:5: PLW0101 Unreachable code in `raise_exception` 86 | raise Exception 87 | return "unreachable" | ^^^^^^^^^^^^^^^^^^^^ PLW0101 -88 | +88 | 89 | def while_false(): | @@ -157,7 +156,7 @@ unreachable.py:105:5: PLW0101 Unreachable code in `while_false_else_return` 104 | return "reachable" 105 | return "also unreachable" | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0101 -106 | +106 | 107 | def while_true(): | @@ -167,7 +166,7 @@ unreachable.py:110:5: PLW0101 Unreachable code in `while_true` 109 | return "reachable" 110 | return "unreachable" | ^^^^^^^^^^^^^^^^^^^^ PLW0101 -111 | +111 | 112 | def while_true_else(): | @@ -177,7 +176,7 @@ unreachable.py:116:9: PLW0101 Unreachable code in `while_true_else` 115 | else: 116 | return "unreachable" | ^^^^^^^^^^^^^^^^^^^^ PLW0101 -117 | +117 | 118 | def while_true_else_return(): | @@ -185,11 +184,10 @@ unreachable.py:122:9: PLW0101 Unreachable code in `while_true_else_return` | 120 | return "reachable" 121 | else: -122 | return "unreachable" - | _________^ +122 | / return "unreachable" 123 | | return "also unreachable" | |_____________________________^ PLW0101 -124 | +124 | 125 | def while_false_var_i(): | @@ -208,7 +206,7 @@ unreachable.py:135:5: PLW0101 Unreachable code in `while_true_var_i` 134 | i += 1 135 | return i | ^^^^^^^^ PLW0101 -136 | +136 | 137 | def while_infinite(): | @@ -218,7 +216,7 @@ unreachable.py:140:5: PLW0101 Unreachable code in `while_infinite` 139 | pass 140 | return "unreachable" | ^^^^^^^^^^^^^^^^^^^^ PLW0101 -141 | +141 | 142 | def while_if_true(): | @@ -228,7 +226,7 @@ unreachable.py:146:5: PLW0101 Unreachable code in `while_if_true` 145 | return "reachable" 146 | return "unreachable" | ^^^^^^^^^^^^^^^^^^^^ PLW0101 -147 | +147 | 148 | def while_break(): | @@ -245,8 +243,7 @@ unreachable.py:248:5: PLW0101 Unreachable code in `after_return` | 246 | def after_return(): 247 | return "reachable" -248 | print("unreachable") - | _____^ +248 | / print("unreachable") 249 | | print("unreachable") 250 | | print("unreachable") 251 | | print("unreachable") @@ -258,8 +255,7 @@ unreachable.py:257:5: PLW0101 Unreachable code in `check_if_url_exists` | 255 | def check_if_url_exists(url: str) -> bool: # type: ignore[return] 256 | return True # uncomment to check URLs -257 | response = requests.head(url, allow_redirects=True) - | _____^ +257 | / response = requests.head(url, allow_redirects=True) 258 | | if response.status_code == 200: 259 | | return True 260 | | if response.status_code == 404: diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP012.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP012.py.snap index 47cb1dc8151df..99b2f05d6e28e 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP012.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP012.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP012.py:2:1: UP012 [*] Unnecessary call to `encode` as UTF-8 | @@ -130,7 +129,7 @@ UP012.py:8:1: UP012 [*] Unnecessary call to `encode` as UTF-8 7 | "foo".encode(encoding="utf-8") # b"foo" 8 | / """ 9 | | Lorem -10 | | +10 | | 11 | | Ipsum 12 | | """.encode( 13 | | "utf-8" @@ -162,8 +161,7 @@ UP012.py:16:5: UP012 [*] Unnecessary call to `encode` as UTF-8 | 14 | ) 15 | ( -16 | "Lorem " - | _____^ +16 | / "Lorem " 17 | | "Ipsum".encode() | |____________________^ UP012 18 | ) @@ -187,8 +185,7 @@ UP012.py:20:5: UP012 [*] Unnecessary call to `encode` as UTF-8 | 18 | ) 19 | ( -20 | "Lorem " # Comment - | _____^ +20 | / "Lorem " # Comment 21 | | "Ipsum".encode() # Comment | |____________________^ UP012 22 | ) @@ -256,7 +253,7 @@ UP012.py:36:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` 37 | | "utf-8", 38 | | ) | |_^ UP012 -39 | +39 | 40 | # `encode` with custom args and kwargs should not be processed. | = help: Remove unnecessary `encoding` argument @@ -299,7 +296,7 @@ UP012.py:55:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` 54 | "unicode text©".encode() 55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 -56 | +56 | 57 | r"foo\o".encode("utf-8") # br"foo\o" | = help: Remove unnecessary `encoding` argument @@ -317,7 +314,7 @@ UP012.py:55:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` UP012.py:57:1: UP012 [*] Unnecessary call to `encode` as UTF-8 | 55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode() -56 | +56 | 57 | r"foo\o".encode("utf-8") # br"foo\o" | ^^^^^^^^^^^^^^^^^^^^^^^^ UP012 58 | u"foo".encode("utf-8") # b"foo" @@ -402,7 +399,7 @@ UP012.py:61:7: UP012 [*] Unnecessary call to `encode` as UTF-8 60 | U"foo".encode("utf-8") # b"foo" 61 | print("foo".encode()) # print(b"foo") | ^^^^^^^^^^^^^^ UP012 -62 | +62 | 63 | # `encode` on parenthesized strings. | = help: Rewrite as bytes literal @@ -425,7 +422,7 @@ UP012.py:64:1: UP012 [*] Unnecessary call to `encode` as UTF-8 66 | | "def" 67 | | ).encode() | |__________^ UP012 -68 | +68 | 69 | (( | = help: Rewrite as bytes literal @@ -447,13 +444,13 @@ UP012.py:64:1: UP012 [*] Unnecessary call to `encode` as UTF-8 UP012.py:69:1: UP012 [*] Unnecessary call to `encode` as UTF-8 | 67 | ).encode() -68 | +68 | 69 | / (( 70 | | "abc" 71 | | "def" 72 | | )).encode() | |___________^ UP012 -73 | +73 | 74 | (f"foo{bar}").encode("utf-8") | = help: Rewrite as bytes literal @@ -475,7 +472,7 @@ UP012.py:69:1: UP012 [*] Unnecessary call to `encode` as UTF-8 UP012.py:74:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` | 72 | )).encode() -73 | +73 | 74 | (f"foo{bar}").encode("utf-8") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 75 | (f"foo{bar}").encode(encoding="utf-8") @@ -558,7 +555,7 @@ UP012.py:82:17: UP012 [*] Unnecessary call to `encode` as UTF-8 81 | def _match_ignore(line): 82 | input=stdin and'\n'.encode()or None | ^^^^^^^^^^^^^ UP012 -83 | +83 | 84 | # Not a valid type annotation but this test shouldn't result in a panic. | = help: Rewrite as bytes literal diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP026.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP026.py.snap index e1f907ac2e373..83ef343e8ecc1 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP026.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP026.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP026.py:3:12: UP026 [*] `mock` is deprecated, use `unittest.mock` | @@ -8,7 +7,7 @@ UP026.py:3:12: UP026 [*] `mock` is deprecated, use `unittest.mock` 2 | if True: 3 | import mock | ^^^^ UP026 -4 | +4 | 5 | # Error (`from unittest import mock`) | = help: Import from `unittest.mock` instead @@ -28,7 +27,7 @@ UP026.py:7:12: UP026 [*] `mock` is deprecated, use `unittest.mock` 6 | if True: 7 | import mock, sys | ^^^^ UP026 -8 | +8 | 9 | # Error (`from unittest.mock import *`) | = help: Import from `unittest.mock` instead @@ -50,7 +49,7 @@ UP026.py:11:5: UP026 [*] `mock` is deprecated, use `unittest.mock` 10 | if True: 11 | from mock import * | ^^^^^^^^^^^^^^^^^^ UP026 -12 | +12 | 13 | # Error (`from unittest import mock`) | = help: Import from `unittest.mock` instead @@ -70,7 +69,7 @@ UP026.py:14:8: UP026 [*] `mock` is deprecated, use `unittest.mock` 13 | # Error (`from unittest import mock`) 14 | import mock.mock | ^^^^^^^^^ UP026 -15 | +15 | 16 | # Error (`from unittest import mock`) | = help: Import from `unittest.mock` instead @@ -90,7 +89,7 @@ UP026.py:17:20: UP026 [*] `mock` is deprecated, use `unittest.mock` 16 | # Error (`from unittest import mock`) 17 | import contextlib, mock, sys | ^^^^ UP026 -18 | +18 | 19 | # Error (`from unittest import mock`) | = help: Import from `unittest.mock` instead @@ -131,7 +130,7 @@ UP026.py:24:1: UP026 [*] `mock` is deprecated, use `unittest.mock` 23 | # Error (`from unittest import mock`) 24 | from mock import mock | ^^^^^^^^^^^^^^^^^^^^^ UP026 -25 | +25 | 26 | # Error (keep trailing comma) | = help: Import from `unittest.mock` instead @@ -188,7 +187,7 @@ UP026.py:33:1: UP026 [*] `mock` is deprecated, use `unittest.mock` 37 | | mock, 38 | | ) | |_^ UP026 -39 | +39 | 40 | # Error (avoid trailing comma) | = help: Import from `unittest.mock` instead @@ -300,7 +299,7 @@ UP026.py:54:1: UP026 [*] `mock` is deprecated, use `unittest.mock` 53 | from mock import mock, a, b, c 54 | from mock import a, b, c, mock | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP026 -55 | +55 | 56 | if True: | = help: Import from `unittest.mock` instead @@ -320,15 +319,14 @@ UP026.py:58:9: UP026 [*] `mock` is deprecated, use `unittest.mock` | 56 | if True: 57 | if False: -58 | from mock import ( - | _________^ +58 | / from mock import ( 59 | | mock, 60 | | a, 61 | | b, 62 | | c 63 | | ) | |_________^ UP026 -64 | +64 | 65 | # OK | = help: Import from `unittest.mock` instead @@ -354,7 +352,7 @@ UP026.py:69:8: UP026 [*] `mock` is deprecated, use `unittest.mock` 68 | # Error (`from unittest import mock`) 69 | import mock, mock | ^^^^ UP026 -70 | +70 | 71 | # Error (`from unittest import mock as foo`) | = help: Import from `unittest.mock` instead @@ -375,7 +373,7 @@ UP026.py:69:14: UP026 [*] `mock` is deprecated, use `unittest.mock` 68 | # Error (`from unittest import mock`) 69 | import mock, mock | ^^^^ UP026 -70 | +70 | 71 | # Error (`from unittest import mock as foo`) | = help: Import from `unittest.mock` instead @@ -396,7 +394,7 @@ UP026.py:72:8: UP026 [*] `mock` is deprecated, use `unittest.mock` 71 | # Error (`from unittest import mock as foo`) 72 | import mock as foo | ^^^^^^^^^^^ UP026 -73 | +73 | 74 | # Error (`from unittest import mock as foo`) | = help: Import from `unittest.mock` instead @@ -416,7 +414,7 @@ UP026.py:75:1: UP026 [*] `mock` is deprecated, use `unittest.mock` 74 | # Error (`from unittest import mock as foo`) 75 | from mock import mock as foo | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP026 -76 | +76 | 77 | if True: | = help: Import from `unittest.mock` instead @@ -437,7 +435,7 @@ UP026.py:79:12: UP026 [*] `mock` is deprecated, use `unittest.mock` 78 | # This should yield multiple, aliased imports. 79 | import mock as foo, mock as bar, mock | ^^^^^^^^^^^ UP026 -80 | +80 | 81 | # This should yield multiple, aliased imports, and preserve `os`. | = help: Import from `unittest.mock` instead @@ -460,7 +458,7 @@ UP026.py:79:25: UP026 [*] `mock` is deprecated, use `unittest.mock` 78 | # This should yield multiple, aliased imports. 79 | import mock as foo, mock as bar, mock | ^^^^^^^^^^^ UP026 -80 | +80 | 81 | # This should yield multiple, aliased imports, and preserve `os`. | = help: Import from `unittest.mock` instead @@ -483,7 +481,7 @@ UP026.py:79:38: UP026 [*] `mock` is deprecated, use `unittest.mock` 78 | # This should yield multiple, aliased imports. 79 | import mock as foo, mock as bar, mock | ^^^^ UP026 -80 | +80 | 81 | # This should yield multiple, aliased imports, and preserve `os`. | = help: Import from `unittest.mock` instead @@ -505,7 +503,7 @@ UP026.py:82:12: UP026 [*] `mock` is deprecated, use `unittest.mock` 81 | # This should yield multiple, aliased imports, and preserve `os`. 82 | import mock as foo, mock as bar, mock, os | ^^^^^^^^^^^ UP026 -83 | +83 | 84 | if True: | = help: Import from `unittest.mock` instead @@ -528,7 +526,7 @@ UP026.py:82:25: UP026 [*] `mock` is deprecated, use `unittest.mock` 81 | # This should yield multiple, aliased imports, and preserve `os`. 82 | import mock as foo, mock as bar, mock, os | ^^^^^^^^^^^ UP026 -83 | +83 | 84 | if True: | = help: Import from `unittest.mock` instead @@ -551,7 +549,7 @@ UP026.py:82:38: UP026 [*] `mock` is deprecated, use `unittest.mock` 81 | # This should yield multiple, aliased imports, and preserve `os`. 82 | import mock as foo, mock as bar, mock, os | ^^^^ UP026 -83 | +83 | 84 | if True: | = help: Import from `unittest.mock` instead diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP028_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP028_0.py.snap index b29e86af3898c..cf0f292036f9b 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP028_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP028_0.py.snap @@ -1,12 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP028_0.py:2:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | 1 | def f(): -2 | for x in y: - | _____^ +2 | / for x in y: 3 | | yield x | |_______________^ UP028 | @@ -24,8 +22,7 @@ UP028_0.py:2:5: UP028 [*] Replace `yield` over `for` loop with `yield from` UP028_0.py:7:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | 6 | def g(): -7 | for x, y in z: - | _____^ +7 | / for x, y in z: 8 | | yield (x, y) | |____________________^ UP028 | @@ -45,8 +42,7 @@ UP028_0.py:7:5: UP028 [*] Replace `yield` over `for` loop with `yield from` UP028_0.py:12:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | 11 | def h(): -12 | for x in [1, 2, 3]: - | _____^ +12 | / for x in [1, 2, 3]: 13 | | yield x | |_______________^ UP028 | @@ -66,8 +62,7 @@ UP028_0.py:12:5: UP028 [*] Replace `yield` over `for` loop with `yield from` UP028_0.py:17:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | 16 | def i(): -17 | for x in {x for x in y}: - | _____^ +17 | / for x in {x for x in y}: 18 | | yield x | |_______________^ UP028 | @@ -87,8 +82,7 @@ UP028_0.py:17:5: UP028 [*] Replace `yield` over `for` loop with `yield from` UP028_0.py:22:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | 21 | def j(): -22 | for x in (1, 2, 3): - | _____^ +22 | / for x in (1, 2, 3): 23 | | yield x | |_______________^ UP028 | @@ -108,8 +102,7 @@ UP028_0.py:22:5: UP028 [*] Replace `yield` over `for` loop with `yield from` UP028_0.py:27:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | 26 | def k(): -27 | for x, y in {3: "x", 6: "y"}: - | _____^ +27 | / for x, y in {3: "x", 6: "y"}: 28 | | yield x, y | |__________________^ UP028 | @@ -130,8 +123,7 @@ UP028_0.py:33:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | 31 | def f(): # Comment one\n' 32 | # Comment two\n' -33 | for x, y in { # Comment three\n' - | _____^ +33 | / for x, y in { # Comment three\n' 34 | | 3: "x", # Comment four\n' 35 | | # Comment five\n' 36 | | 6: "y", # Comment six\n' @@ -163,8 +155,7 @@ UP028_0.py:33:5: UP028 [*] Replace `yield` over `for` loop with `yield from` UP028_0.py:44:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | 43 | def f(): -44 | for x, y in [{3: (3, [44, "long ss"]), 6: "y"}]: - | _____^ +44 | / for x, y in [{3: (3, [44, "long ss"]), 6: "y"}]: 45 | | yield x, y | |__________________^ UP028 | @@ -184,11 +175,10 @@ UP028_0.py:44:5: UP028 [*] Replace `yield` over `for` loop with `yield from` UP028_0.py:49:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | 48 | def f(): -49 | for x, y in z(): - | _____^ +49 | / for x, y in z(): 50 | | yield x, y | |__________________^ UP028 -51 | +51 | 52 | def f(): | = help: Replace with `yield from` @@ -208,8 +198,7 @@ UP028_0.py:55:9: UP028 [*] Replace `yield` over `for` loop with `yield from` | 53 | def func(): 54 | # This comment is preserved\n' -55 | for x, y in z(): # Comment one\n' - | _________^ +55 | / for x, y in z(): # Comment one\n' 56 | | # Comment two\n' 57 | | yield x, y # Comment three\n' | |______________________^ UP028 @@ -234,8 +223,7 @@ UP028_0.py:67:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | 65 | for x in y: 66 | yield x -67 | for z in x: - | _____^ +67 | / for z in x: 68 | | yield z | |_______________^ UP028 | @@ -255,8 +243,7 @@ UP028_0.py:67:5: UP028 [*] Replace `yield` over `for` loop with `yield from` UP028_0.py:72:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | 71 | def f(): -72 | for x, y in z(): - | _____^ +72 | / for x, y in z(): 73 | | yield x, y | |__________________^ UP028 74 | x = 1 @@ -278,8 +265,7 @@ UP028_0.py:79:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | 77 | # Regression test for: https://github.com/astral-sh/ruff/issues/7103 78 | def _serve_method(fn): -79 | for h in ( - | _____^ +79 | / for h in ( 80 | | TaggedText.from_file(args.input) 81 | | .markup(highlight=args.region) 82 | | ): @@ -307,8 +293,7 @@ UP028_0.py:97:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | 95 | # UP028: The exception binding is not a reference to the loop variable 96 | def f(): - 97 | for x in (1, 2, 3): - | _____^ + 97 | / for x in (1, 2, 3): 98 | | yield x | |_______________^ UP028 99 | # Shadowing with an `except` @@ -331,8 +316,7 @@ UP028_0.py:108:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | 106 | # UP028: The context binding is not a reference to the loop variable 107 | def f(): -108 | for x in (1, 2, 3): - | _____^ +108 | / for x in (1, 2, 3): 109 | | yield x | |_______________^ UP028 110 | # Shadowing with `with` @@ -355,8 +339,7 @@ UP028_0.py:118:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | 116 | # UP028: The type annotation binding is not a reference to the loop variable 117 | def f(): -118 | for x in (1, 2, 3): - | _____^ +118 | / for x in (1, 2, 3): 119 | | yield x | |_______________^ UP028 120 | # Shadowing with a type annotation @@ -379,8 +362,7 @@ UP028_0.py:134:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | 132 | # UP028: The exception bindings are not a reference to the loop variable 133 | def f(): -134 | for x in (1, 2, 3): - | _____^ +134 | / for x in (1, 2, 3): 135 | | yield x | |_______________^ UP028 136 | # Shadowing with multiple `except` blocks diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP030_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP030_0.py.snap index 28e2b01264b0f..1f17a77cef01e 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP030_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP030_0.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP030_0.py:3:1: UP030 [*] Use implicit references for positional format fields | 1 | # Invalid calls; errors expected. -2 | +2 | 3 | "{0}" "{1}" "{2}".format(1, 2, 3) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -4 | +4 | 5 | "a {3} complicated {1} string with {0} {2}".format( | = help: Remove explicit positional indices @@ -25,12 +24,12 @@ UP030_0.py:3:1: UP030 [*] Use implicit references for positional format fields UP030_0.py:5:1: UP030 [*] Use implicit references for positional format fields | 3 | "{0}" "{1}" "{2}".format(1, 2, 3) -4 | +4 | 5 | / "a {3} complicated {1} string with {0} {2}".format( 6 | | "first", "second", "third", "fourth" 7 | | ) | |_^ UP030 -8 | +8 | 9 | '{0}'.format(1) | = help: Remove explicit positional indices @@ -50,10 +49,10 @@ UP030_0.py:5:1: UP030 [*] Use implicit references for positional format fields UP030_0.py:9:1: UP030 [*] Use implicit references for positional format fields | 7 | ) - 8 | + 8 | 9 | '{0}'.format(1) | ^^^^^^^^^^^^^^^ UP030 -10 | +10 | 11 | '{0:x}'.format(30) | = help: Remove explicit positional indices @@ -71,10 +70,10 @@ UP030_0.py:9:1: UP030 [*] Use implicit references for positional format fields UP030_0.py:11:1: UP030 [*] Use implicit references for positional format fields | 9 | '{0}'.format(1) -10 | +10 | 11 | '{0:x}'.format(30) | ^^^^^^^^^^^^^^^^^^ UP030 -12 | +12 | 13 | x = '{0}'.format(1) | = help: Remove explicit positional indices @@ -92,10 +91,10 @@ UP030_0.py:11:1: UP030 [*] Use implicit references for positional format fields UP030_0.py:13:5: UP030 [*] Use implicit references for positional format fields | 11 | '{0:x}'.format(30) -12 | +12 | 13 | x = '{0}'.format(1) | ^^^^^^^^^^^^^^^ UP030 -14 | +14 | 15 | '''{0}\n{1}\n'''.format(1, 2) | = help: Remove explicit positional indices @@ -113,10 +112,10 @@ UP030_0.py:13:5: UP030 [*] Use implicit references for positional format fields UP030_0.py:15:1: UP030 [*] Use implicit references for positional format fields | 13 | x = '{0}'.format(1) -14 | +14 | 15 | '''{0}\n{1}\n'''.format(1, 2) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -16 | +16 | 17 | x = "foo {0}" \ | = help: Remove explicit positional indices @@ -134,12 +133,12 @@ UP030_0.py:15:1: UP030 [*] Use implicit references for positional format fields UP030_0.py:17:5: UP030 [*] Use implicit references for positional format fields | 15 | '''{0}\n{1}\n'''.format(1, 2) -16 | +16 | 17 | x = "foo {0}" \ | _____^ 18 | | "bar {1}".format(1, 2) | |__________________________^ UP030 -19 | +19 | 20 | ("{0}").format(1) | = help: Remove explicit positional indices @@ -159,10 +158,10 @@ UP030_0.py:17:5: UP030 [*] Use implicit references for positional format fields UP030_0.py:20:1: UP030 [*] Use implicit references for positional format fields | 18 | "bar {1}".format(1, 2) -19 | +19 | 20 | ("{0}").format(1) | ^^^^^^^^^^^^^^^^^ UP030 -21 | +21 | 22 | "\N{snowman} {0}".format(1) | = help: Remove explicit positional indices @@ -180,10 +179,10 @@ UP030_0.py:20:1: UP030 [*] Use implicit references for positional format fields UP030_0.py:22:1: UP030 [*] Use implicit references for positional format fields | 20 | ("{0}").format(1) -21 | +21 | 22 | "\N{snowman} {0}".format(1) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -23 | +23 | 24 | print( | = help: Remove explicit positional indices @@ -201,8 +200,7 @@ UP030_0.py:22:1: UP030 [*] Use implicit references for positional format fields UP030_0.py:25:5: UP030 [*] Use implicit references for positional format fields | 24 | print( -25 | 'foo{0}' - | _____^ +25 | / 'foo{0}' 26 | | 'bar{1}'.format(1, 2) | |_________________________^ UP030 27 | ) @@ -224,8 +222,7 @@ UP030_0.py:25:5: UP030 [*] Use implicit references for positional format fields UP030_0.py:30:5: UP030 [*] Use implicit references for positional format fields | 29 | print( -30 | 'foo{0}' # ohai\n" - | _____^ +30 | / 'foo{0}' # ohai\n" 31 | | 'bar{1}'.format(1, 2) | |_________________________^ UP030 32 | ) @@ -247,10 +244,10 @@ UP030_0.py:30:5: UP030 [*] Use implicit references for positional format fields UP030_0.py:34:1: UP030 Use implicit references for positional format fields | 32 | ) -33 | +33 | 34 | '{' '0}'.format(1) | ^^^^^^^^^^^^^^^^^^ UP030 -35 | +35 | 36 | args = list(range(10)) | = help: Remove explicit positional indices @@ -258,10 +255,10 @@ UP030_0.py:34:1: UP030 Use implicit references for positional format fields UP030_0.py:39:1: UP030 [*] Use implicit references for positional format fields | 37 | kwargs = {x: x for x in range(10)} -38 | +38 | 39 | "{0}".format(*args) | ^^^^^^^^^^^^^^^^^^^ UP030 -40 | +40 | 41 | "{0}".format(**kwargs) | = help: Remove explicit positional indices @@ -279,10 +276,10 @@ UP030_0.py:39:1: UP030 [*] Use implicit references for positional format fields UP030_0.py:41:1: UP030 [*] Use implicit references for positional format fields | 39 | "{0}".format(*args) -40 | +40 | 41 | "{0}".format(**kwargs) | ^^^^^^^^^^^^^^^^^^^^^^ UP030 -42 | +42 | 43 | "{0}_{1}".format(*args) | = help: Remove explicit positional indices @@ -300,10 +297,10 @@ UP030_0.py:41:1: UP030 [*] Use implicit references for positional format fields UP030_0.py:43:1: UP030 [*] Use implicit references for positional format fields | 41 | "{0}".format(**kwargs) -42 | +42 | 43 | "{0}_{1}".format(*args) | ^^^^^^^^^^^^^^^^^^^^^^^ UP030 -44 | +44 | 45 | "{0}_{1}".format(1, *args) | = help: Remove explicit positional indices @@ -321,10 +318,10 @@ UP030_0.py:43:1: UP030 [*] Use implicit references for positional format fields UP030_0.py:45:1: UP030 [*] Use implicit references for positional format fields | 43 | "{0}_{1}".format(*args) -44 | +44 | 45 | "{0}_{1}".format(1, *args) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -46 | +46 | 47 | "{0}_{1}".format(1, 2, *args) | = help: Remove explicit positional indices @@ -342,10 +339,10 @@ UP030_0.py:45:1: UP030 [*] Use implicit references for positional format fields UP030_0.py:47:1: UP030 [*] Use implicit references for positional format fields | 45 | "{0}_{1}".format(1, *args) -46 | +46 | 47 | "{0}_{1}".format(1, 2, *args) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -48 | +48 | 49 | "{0}_{1}".format(*args, 1, 2) | = help: Remove explicit positional indices @@ -363,10 +360,10 @@ UP030_0.py:47:1: UP030 [*] Use implicit references for positional format fields UP030_0.py:49:1: UP030 [*] Use implicit references for positional format fields | 47 | "{0}_{1}".format(1, 2, *args) -48 | +48 | 49 | "{0}_{1}".format(*args, 1, 2) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -50 | +50 | 51 | "{0}_{1}_{2}".format(1, **kwargs) | = help: Remove explicit positional indices @@ -384,10 +381,10 @@ UP030_0.py:49:1: UP030 [*] Use implicit references for positional format fields UP030_0.py:51:1: UP030 [*] Use implicit references for positional format fields | 49 | "{0}_{1}".format(*args, 1, 2) -50 | +50 | 51 | "{0}_{1}_{2}".format(1, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -52 | +52 | 53 | "{0}_{1}_{2}".format(1, 2, **kwargs) | = help: Remove explicit positional indices @@ -405,10 +402,10 @@ UP030_0.py:51:1: UP030 [*] Use implicit references for positional format fields UP030_0.py:53:1: UP030 [*] Use implicit references for positional format fields | 51 | "{0}_{1}_{2}".format(1, **kwargs) -52 | +52 | 53 | "{0}_{1}_{2}".format(1, 2, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -54 | +54 | 55 | "{0}_{1}_{2}".format(1, 2, 3, **kwargs) | = help: Remove explicit positional indices @@ -426,10 +423,10 @@ UP030_0.py:53:1: UP030 [*] Use implicit references for positional format fields UP030_0.py:55:1: UP030 [*] Use implicit references for positional format fields | 53 | "{0}_{1}_{2}".format(1, 2, **kwargs) -54 | +54 | 55 | "{0}_{1}_{2}".format(1, 2, 3, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -56 | +56 | 57 | "{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) | = help: Remove explicit positional indices @@ -447,10 +444,10 @@ UP030_0.py:55:1: UP030 [*] Use implicit references for positional format fields UP030_0.py:57:1: UP030 [*] Use implicit references for positional format fields | 55 | "{0}_{1}_{2}".format(1, 2, 3, **kwargs) -56 | +56 | 57 | "{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -58 | +58 | 59 | "{1}_{0}".format(1, 2, *args) | = help: Remove explicit positional indices @@ -468,10 +465,10 @@ UP030_0.py:57:1: UP030 [*] Use implicit references for positional format fields UP030_0.py:59:1: UP030 [*] Use implicit references for positional format fields | 57 | "{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) -58 | +58 | 59 | "{1}_{0}".format(1, 2, *args) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -60 | +60 | 61 | "{1}_{0}".format(1, 2) | = help: Remove explicit positional indices @@ -488,7 +485,7 @@ UP030_0.py:59:1: UP030 [*] Use implicit references for positional format fields UP030_0.py:61:1: UP030 [*] Use implicit references for positional format fields | 59 | "{1}_{0}".format(1, 2, *args) -60 | +60 | 61 | "{1}_{0}".format(1, 2) | ^^^^^^^^^^^^^^^^^^^^^^ UP030 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_0.py.snap index 5e61f226d7eb9..51bd88cd7f65d 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_0.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP032_0.py:5:1: UP032 [*] Use f-string instead of `format` call | 3 | ### -4 | +4 | 5 | "{} {}".format(a, b) | ^^^^^^^^^^^^^^^^^^^^ UP032 -6 | +6 | 7 | "{1} {0}".format(a, b) | = help: Convert to f-string @@ -26,10 +25,10 @@ UP032_0.py:5:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:7:1: UP032 [*] Use f-string instead of `format` call | 5 | "{} {}".format(a, b) -6 | +6 | 7 | "{1} {0}".format(a, b) | ^^^^^^^^^^^^^^^^^^^^^^ UP032 -8 | +8 | 9 | "{0} {1} {0}".format(a, b) | = help: Convert to f-string @@ -47,10 +46,10 @@ UP032_0.py:7:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:9:1: UP032 [*] Use f-string instead of `format` call | 7 | "{1} {0}".format(a, b) - 8 | + 8 | 9 | "{0} {1} {0}".format(a, b) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -10 | +10 | 11 | "{x.y}".format(x=z) | = help: Convert to f-string @@ -68,10 +67,10 @@ UP032_0.py:9:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:11:1: UP032 [*] Use f-string instead of `format` call | 9 | "{0} {1} {0}".format(a, b) -10 | +10 | 11 | "{x.y}".format(x=z) | ^^^^^^^^^^^^^^^^^^^ UP032 -12 | +12 | 13 | "{x} {y} {x}".format(x=a, y=b) | = help: Convert to f-string @@ -89,10 +88,10 @@ UP032_0.py:11:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:13:1: UP032 [*] Use f-string instead of `format` call | 11 | "{x.y}".format(x=z) -12 | +12 | 13 | "{x} {y} {x}".format(x=a, y=b) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -14 | +14 | 15 | "{.x} {.y}".format(a, b) | = help: Convert to f-string @@ -110,10 +109,10 @@ UP032_0.py:13:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:15:1: UP032 [*] Use f-string instead of `format` call | 13 | "{x} {y} {x}".format(x=a, y=b) -14 | +14 | 15 | "{.x} {.y}".format(a, b) | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -16 | +16 | 17 | "{} {}".format(a.b, c.d) | = help: Convert to f-string @@ -131,10 +130,10 @@ UP032_0.py:15:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:17:1: UP032 [*] Use f-string instead of `format` call | 15 | "{.x} {.y}".format(a, b) -16 | +16 | 17 | "{} {}".format(a.b, c.d) | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -18 | +18 | 19 | "{}".format(a()) | = help: Convert to f-string @@ -152,10 +151,10 @@ UP032_0.py:17:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:19:1: UP032 [*] Use f-string instead of `format` call | 17 | "{} {}".format(a.b, c.d) -18 | +18 | 19 | "{}".format(a()) | ^^^^^^^^^^^^^^^^ UP032 -20 | +20 | 21 | "{}".format(a.b()) | = help: Convert to f-string @@ -173,10 +172,10 @@ UP032_0.py:19:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:21:1: UP032 [*] Use f-string instead of `format` call | 19 | "{}".format(a()) -20 | +20 | 21 | "{}".format(a.b()) | ^^^^^^^^^^^^^^^^^^ UP032 -22 | +22 | 23 | "{}".format(a.b().c()) | = help: Convert to f-string @@ -194,10 +193,10 @@ UP032_0.py:21:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:23:1: UP032 [*] Use f-string instead of `format` call | 21 | "{}".format(a.b()) -22 | +22 | 23 | "{}".format(a.b().c()) | ^^^^^^^^^^^^^^^^^^^^^^ UP032 -24 | +24 | 25 | "hello {}!".format(name) | = help: Convert to f-string @@ -215,10 +214,10 @@ UP032_0.py:23:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:25:1: UP032 [*] Use f-string instead of `format` call | 23 | "{}".format(a.b().c()) -24 | +24 | 25 | "hello {}!".format(name) | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -26 | +26 | 27 | "{}{b}{}".format(a, c, b=b) | = help: Convert to f-string @@ -236,10 +235,10 @@ UP032_0.py:25:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:27:1: UP032 [*] Use f-string instead of `format` call | 25 | "hello {}!".format(name) -26 | +26 | 27 | "{}{b}{}".format(a, c, b=b) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -28 | +28 | 29 | "{}".format(0x0) | = help: Convert to f-string @@ -257,10 +256,10 @@ UP032_0.py:27:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:29:1: UP032 [*] Use f-string instead of `format` call | 27 | "{}{b}{}".format(a, c, b=b) -28 | +28 | 29 | "{}".format(0x0) | ^^^^^^^^^^^^^^^^ UP032 -30 | +30 | 31 | "{} {}".format(a, b) | = help: Convert to f-string @@ -278,10 +277,10 @@ UP032_0.py:29:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:31:1: UP032 [*] Use f-string instead of `format` call | 29 | "{}".format(0x0) -30 | +30 | 31 | "{} {}".format(a, b) | ^^^^^^^^^^^^^^^^^^^^ UP032 -32 | +32 | 33 | """{} {}""".format(a, b) | = help: Convert to f-string @@ -299,10 +298,10 @@ UP032_0.py:31:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:33:1: UP032 [*] Use f-string instead of `format` call | 31 | "{} {}".format(a, b) -32 | +32 | 33 | """{} {}""".format(a, b) | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -34 | +34 | 35 | "foo{}".format(1) | = help: Convert to f-string @@ -320,10 +319,10 @@ UP032_0.py:33:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:35:1: UP032 [*] Use f-string instead of `format` call | 33 | """{} {}""".format(a, b) -34 | +34 | 35 | "foo{}".format(1) | ^^^^^^^^^^^^^^^^^ UP032 -36 | +36 | 37 | r"foo{}".format(1) | = help: Convert to f-string @@ -341,10 +340,10 @@ UP032_0.py:35:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:37:1: UP032 [*] Use f-string instead of `format` call | 35 | "foo{}".format(1) -36 | +36 | 37 | r"foo{}".format(1) | ^^^^^^^^^^^^^^^^^^ UP032 -38 | +38 | 39 | x = "{a}".format(a=1) | = help: Convert to f-string @@ -362,10 +361,10 @@ UP032_0.py:37:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:39:5: UP032 [*] Use f-string instead of `format` call | 37 | r"foo{}".format(1) -38 | +38 | 39 | x = "{a}".format(a=1) | ^^^^^^^^^^^^^^^^^ UP032 -40 | +40 | 41 | print("foo {} ".format(x)) | = help: Convert to f-string @@ -383,10 +382,10 @@ UP032_0.py:39:5: UP032 [*] Use f-string instead of `format` call UP032_0.py:41:7: UP032 [*] Use f-string instead of `format` call | 39 | x = "{a}".format(a=1) -40 | +40 | 41 | print("foo {} ".format(x)) | ^^^^^^^^^^^^^^^^^^^ UP032 -42 | +42 | 43 | "{a[b]}".format(a=a) | = help: Convert to f-string @@ -404,10 +403,10 @@ UP032_0.py:41:7: UP032 [*] Use f-string instead of `format` call UP032_0.py:43:1: UP032 [*] Use f-string instead of `format` call | 41 | print("foo {} ".format(x)) -42 | +42 | 43 | "{a[b]}".format(a=a) | ^^^^^^^^^^^^^^^^^^^^ UP032 -44 | +44 | 45 | "{a.a[b]}".format(a=a) | = help: Convert to f-string @@ -425,10 +424,10 @@ UP032_0.py:43:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:45:1: UP032 [*] Use f-string instead of `format` call | 43 | "{a[b]}".format(a=a) -44 | +44 | 45 | "{a.a[b]}".format(a=a) | ^^^^^^^^^^^^^^^^^^^^^^ UP032 -46 | +46 | 47 | "{}{{}}{}".format(escaped, y) | = help: Convert to f-string @@ -446,10 +445,10 @@ UP032_0.py:45:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:47:1: UP032 [*] Use f-string instead of `format` call | 45 | "{a.a[b]}".format(a=a) -46 | +46 | 47 | "{}{{}}{}".format(escaped, y) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -48 | +48 | 49 | "{}".format(a) | = help: Convert to f-string @@ -467,10 +466,10 @@ UP032_0.py:47:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:49:1: UP032 [*] Use f-string instead of `format` call | 47 | "{}{{}}{}".format(escaped, y) -48 | +48 | 49 | "{}".format(a) | ^^^^^^^^^^^^^^ UP032 -50 | +50 | 51 | '({}={{0!e}})'.format(a) | = help: Convert to f-string @@ -488,10 +487,10 @@ UP032_0.py:49:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:51:1: UP032 [*] Use f-string instead of `format` call | 49 | "{}".format(a) -50 | +50 | 51 | '({}={{0!e}})'.format(a) | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -52 | +52 | 53 | "{[b]}".format(a) | = help: Convert to f-string @@ -509,10 +508,10 @@ UP032_0.py:51:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:53:1: UP032 [*] Use f-string instead of `format` call | 51 | '({}={{0!e}})'.format(a) -52 | +52 | 53 | "{[b]}".format(a) | ^^^^^^^^^^^^^^^^^ UP032 -54 | +54 | 55 | '{[b]}'.format(a) | = help: Convert to f-string @@ -530,10 +529,10 @@ UP032_0.py:53:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:55:1: UP032 [*] Use f-string instead of `format` call | 53 | "{[b]}".format(a) -54 | +54 | 55 | '{[b]}'.format(a) | ^^^^^^^^^^^^^^^^^ UP032 -56 | +56 | 57 | """{[b]}""".format(a) | = help: Convert to f-string @@ -551,10 +550,10 @@ UP032_0.py:55:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:57:1: UP032 [*] Use f-string instead of `format` call | 55 | '{[b]}'.format(a) -56 | +56 | 57 | """{[b]}""".format(a) | ^^^^^^^^^^^^^^^^^^^^^ UP032 -58 | +58 | 59 | '''{[b]}'''.format(a) | = help: Convert to f-string @@ -572,10 +571,10 @@ UP032_0.py:57:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:59:1: UP032 [*] Use f-string instead of `format` call | 57 | """{[b]}""".format(a) -58 | +58 | 59 | '''{[b]}'''.format(a) | ^^^^^^^^^^^^^^^^^^^^^ UP032 -60 | +60 | 61 | "{}".format( | = help: Convert to f-string @@ -593,12 +592,12 @@ UP032_0.py:59:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:61:1: UP032 [*] Use f-string instead of `format` call | 59 | '''{[b]}'''.format(a) -60 | +60 | 61 | / "{}".format( 62 | | 1 63 | | ) | |_^ UP032 -64 | +64 | 65 | "123456789 {}".format( | = help: Convert to f-string @@ -618,12 +617,12 @@ UP032_0.py:61:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:65:1: UP032 [*] Use f-string instead of `format` call | 63 | ) -64 | +64 | 65 | / "123456789 {}".format( 66 | | 1111111111111111111111111111111111111111111111111111111111111111111111111, 67 | | ) | |_^ UP032 -68 | +68 | 69 | """ | = help: Convert to f-string @@ -643,12 +642,12 @@ UP032_0.py:65:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:69:1: UP032 [*] Use f-string instead of `format` call | 67 | ) -68 | +68 | 69 | / """ 70 | | {} 71 | | """.format(1) | |_____________^ UP032 -72 | +72 | 73 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = """ | = help: Convert to f-string @@ -669,7 +668,7 @@ UP032_0.py:69:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:73:85: UP032 [*] Use f-string instead of `format` call | 71 | """.format(1) -72 | +72 | 73 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = """ | _____________________________________________________________________________________^ 74 | | {} @@ -677,7 +676,7 @@ UP032_0.py:73:85: UP032 [*] Use f-string instead of `format` call 76 | | 111111 77 | | ) | |_^ UP032 -78 | +78 | 79 | "{a}" "{b}".format(a=1, b=1) | = help: Convert to f-string @@ -701,10 +700,10 @@ UP032_0.py:73:85: UP032 [*] Use f-string instead of `format` call UP032_0.py:79:1: UP032 [*] Use f-string instead of `format` call | 77 | ) -78 | +78 | 79 | "{a}" "{b}".format(a=1, b=1) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -80 | +80 | 81 | ( | = help: Convert to f-string @@ -722,13 +721,13 @@ UP032_0.py:79:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:81:1: UP032 [*] Use f-string instead of `format` call | 79 | "{a}" "{b}".format(a=1, b=1) -80 | +80 | 81 | / ( 82 | | "{a}" 83 | | "{b}" 84 | | ).format(a=1, b=1) | |__________________^ UP032 -85 | +85 | 86 | ( | = help: Convert to f-string @@ -750,7 +749,7 @@ UP032_0.py:81:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:86:1: UP032 [*] Use f-string instead of `format` call | 84 | ).format(a=1, b=1) -85 | +85 | 86 | / ( 87 | | "{a}" 88 | | "" @@ -758,7 +757,7 @@ UP032_0.py:86:1: UP032 [*] Use f-string instead of `format` call 90 | | "" 91 | | ).format(a=1, b=1) | |__________________^ UP032 -92 | +92 | 93 | ( | = help: Convert to f-string @@ -782,8 +781,7 @@ UP032_0.py:86:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:94:5: UP032 [*] Use f-string instead of `format` call | 93 | ( - 94 | ( - | _____^ + 94 | / ( 95 | | # comment 96 | | "{a}" 97 | | # comment @@ -816,7 +814,7 @@ UP032_0.py:94:5: UP032 [*] Use f-string instead of `format` call UP032_0.py:104:1: UP032 [*] Use f-string instead of `format` call | 102 | ) -103 | +103 | 104 | / ( 105 | | "{a}" 106 | | "b" @@ -931,7 +929,7 @@ UP032_0.py:129:1: UP032 [*] Use f-string instead of `format` call | 129 | "{}".format(1 * 2) | ^^^^^^^^^^^^^^^^^^ UP032 -130 | +130 | 131 | ### | = help: Convert to f-string @@ -949,12 +947,12 @@ UP032_0.py:129:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:160:1: UP032 [*] Use f-string instead of `format` call | 158 | r'"\N{snowman} {}".format(a)' -159 | +159 | 160 | / "123456789 {}".format( 161 | | 11111111111111111111111111111111111111111111111111111111111111111111111111, 162 | | ) | |_^ UP032 -163 | +163 | 164 | """ | = help: Convert to f-string @@ -974,7 +972,7 @@ UP032_0.py:160:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:164:1: UP032 [*] Use f-string instead of `format` call | 162 | ) -163 | +163 | 164 | / """ 165 | | {} 166 | | {} @@ -985,7 +983,7 @@ UP032_0.py:164:1: UP032 [*] Use f-string instead of `format` call 171 | | 111111111111111111111111111111111111111111111111111111111111111111111111111111111111111, 172 | | ) | |_^ UP032 -173 | +173 | 174 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = """{} | = help: Convert to f-string @@ -1014,14 +1012,14 @@ UP032_0.py:164:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:174:84: UP032 [*] Use f-string instead of `format` call | 172 | ) -173 | +173 | 174 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = """{} | ____________________________________________________________________________________^ 175 | | """.format( 176 | | 111111 177 | | ) | |_^ UP032 -178 | +178 | 179 | "{}".format( | = help: Convert to f-string @@ -1043,7 +1041,7 @@ UP032_0.py:174:84: UP032 [*] Use f-string instead of `format` call UP032_0.py:202:1: UP032 Use f-string instead of `format` call | 200 | "{}".format(**c) -201 | +201 | 202 | / "{}".format( 203 | | 1 # comment 204 | | ) @@ -1057,7 +1055,7 @@ UP032_0.py:209:1: UP032 [*] Use f-string instead of `format` call 208 | # existing line length, so it's fine. 209 | "".format(self.internal_ids, self.external_ids, self.properties, self.tags, self.others) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -210 | +210 | 211 | # When fixing, trim the trailing empty string. | = help: Convert to f-string @@ -1079,7 +1077,7 @@ UP032_0.py:212:18: UP032 [*] Use f-string instead of `format` call | __________________^ 213 | | "".format(new_dict, d)) | |_______________________________________^ UP032 -214 | +214 | 215 | # When fixing, trim the trailing empty string. | = help: Convert to f-string @@ -1102,7 +1100,7 @@ UP032_0.py:216:18: UP032 [*] Use f-string instead of `format` call | __________________^ 217 | | .format(new_dict, d)) | |_____________________________________^ UP032 -218 | +218 | 219 | raise ValueError( | = help: Convert to f-string @@ -1122,8 +1120,7 @@ UP032_0.py:216:18: UP032 [*] Use f-string instead of `format` call UP032_0.py:220:5: UP032 [*] Use f-string instead of `format` call | 219 | raise ValueError( -220 | "Conflicting configuration dicts: {!r} {!r}" - | _____^ +220 | / "Conflicting configuration dicts: {!r} {!r}" 221 | | "".format(new_dict, d) | |__________________________^ UP032 222 | ) @@ -1144,11 +1141,10 @@ UP032_0.py:220:5: UP032 [*] Use f-string instead of `format` call UP032_0.py:225:5: UP032 [*] Use f-string instead of `format` call | 224 | raise ValueError( -225 | "Conflicting configuration dicts: {!r} {!r}" - | _____^ +225 | / "Conflicting configuration dicts: {!r} {!r}" 226 | | "".format(new_dict, d) | |__________________________^ UP032 -227 | +227 | 228 | ) | = help: Convert to f-string @@ -1172,7 +1168,7 @@ UP032_0.py:231:1: UP032 [*] Use f-string instead of `format` call 233 | | "{{}}" 234 | | ).format(a) | |___________^ UP032 -235 | +235 | 236 | ("{}" "{{}}").format(a) | = help: Convert to f-string @@ -1193,7 +1189,7 @@ UP032_0.py:231:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:236:1: UP032 [*] Use f-string instead of `format` call | 234 | ).format(a) -235 | +235 | 236 | ("{}" "{{}}").format(a) | ^^^^^^^^^^^^^^^^^^^^^^^ UP032 | @@ -1217,7 +1213,7 @@ UP032_0.py:240:1: UP032 [*] Use f-string instead of `format` call 242 | | "{{{}}}" 243 | | ).format(a, b) | |______________^ UP032 -244 | +244 | 245 | ("{}" "{{{}}}").format(a, b) | = help: Convert to f-string @@ -1239,10 +1235,10 @@ UP032_0.py:240:1: UP032 [*] Use f-string instead of `format` call UP032_0.py:245:1: UP032 [*] Use f-string instead of `format` call | 243 | ).format(a, b) -244 | +244 | 245 | ("{}" "{{{}}}").format(a, b) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -246 | +246 | 247 | # The dictionary should be parenthesized. | = help: Convert to f-string @@ -1262,7 +1258,7 @@ UP032_0.py:248:1: UP032 [*] Use f-string instead of `format` call 247 | # The dictionary should be parenthesized. 248 | "{}".format({0: 1}[0]) | ^^^^^^^^^^^^^^^^^^^^^^ UP032 -249 | +249 | 250 | # The dictionary should be parenthesized. | = help: Convert to f-string @@ -1282,7 +1278,7 @@ UP032_0.py:251:1: UP032 [*] Use f-string instead of `format` call 250 | # The dictionary should be parenthesized. 251 | "{}".format({0: 1}.bar) | ^^^^^^^^^^^^^^^^^^^^^^^ UP032 -252 | +252 | 253 | # The dictionary should be parenthesized. | = help: Convert to f-string @@ -1302,7 +1298,7 @@ UP032_0.py:254:1: UP032 [*] Use f-string instead of `format` call 253 | # The dictionary should be parenthesized. 254 | "{}".format({0: 1}()) | ^^^^^^^^^^^^^^^^^^^^^ UP032 -255 | +255 | 256 | # The string shouldn't be converted, since it would require repeating the function call. | = help: Convert to f-string @@ -1322,7 +1318,7 @@ UP032_0.py:261:1: UP032 [*] Use f-string instead of `format` call 260 | # The string _should_ be converted, since the function call is repeated in the arguments. 261 | "{0} {1}".format(foo(), foo()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -262 | +262 | 263 | # The call should be removed, but the string itself should remain. | = help: Convert to f-string @@ -1342,7 +1338,7 @@ UP032_0.py:264:1: UP032 [*] Use f-string instead of `format` call 263 | # The call should be removed, but the string itself should remain. 264 | ''.format(self.project) | ^^^^^^^^^^^^^^^^^^^^^^^ UP032 -265 | +265 | 266 | # The call should be removed, but the string itself should remain. | = help: Convert to f-string @@ -1362,7 +1358,7 @@ UP032_0.py:267:1: UP032 [*] Use f-string instead of `format` call 266 | # The call should be removed, but the string itself should remain. 267 | "".format(self.project) | ^^^^^^^^^^^^^^^^^^^^^^^ UP032 -268 | +268 | 269 | # Not a valid type annotation but this test shouldn't result in a panic. | = help: Convert to f-string diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP035.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP035.py.snap index b63110f6231e7..5b61202887dd2 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP035.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP035.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- UP035.py:2:1: UP035 [*] Import from `collections.abc` instead: `Mapping` | 1 | # UP035 2 | from collections import Mapping | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -3 | +3 | 4 | from collections import Mapping as MAP | = help: Import from `collections.abc` @@ -23,10 +22,10 @@ UP035.py:2:1: UP035 [*] Import from `collections.abc` instead: `Mapping` UP035.py:4:1: UP035 [*] Import from `collections.abc` instead: `Mapping` | 2 | from collections import Mapping -3 | +3 | 4 | from collections import Mapping as MAP | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -5 | +5 | 6 | from collections import Mapping, Sequence | = help: Import from `collections.abc` @@ -44,10 +43,10 @@ UP035.py:4:1: UP035 [*] Import from `collections.abc` instead: `Mapping` UP035.py:6:1: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Sequence` | 4 | from collections import Mapping as MAP -5 | +5 | 6 | from collections import Mapping, Sequence | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -7 | +7 | 8 | from collections import Counter, Mapping | = help: Import from `collections.abc` @@ -65,10 +64,10 @@ UP035.py:6:1: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Seque UP035.py:8:1: UP035 [*] Import from `collections.abc` instead: `Mapping` | 6 | from collections import Mapping, Sequence - 7 | + 7 | 8 | from collections import Counter, Mapping | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 - 9 | + 9 | 10 | from collections import (Counter, Mapping) | = help: Import from `collections.abc` @@ -87,10 +86,10 @@ UP035.py:8:1: UP035 [*] Import from `collections.abc` instead: `Mapping` UP035.py:10:1: UP035 [*] Import from `collections.abc` instead: `Mapping` | 8 | from collections import Counter, Mapping - 9 | + 9 | 10 | from collections import (Counter, Mapping) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -11 | +11 | 12 | from collections import (Counter, | = help: Import from `collections.abc` @@ -109,11 +108,11 @@ UP035.py:10:1: UP035 [*] Import from `collections.abc` instead: `Mapping` UP035.py:12:1: UP035 [*] Import from `collections.abc` instead: `Mapping` | 10 | from collections import (Counter, Mapping) -11 | +11 | 12 | / from collections import (Counter, 13 | | Mapping) | |_________________________________^ UP035 -14 | +14 | 15 | from collections import Counter, \ | = help: Import from `collections.abc` @@ -133,11 +132,11 @@ UP035.py:12:1: UP035 [*] Import from `collections.abc` instead: `Mapping` UP035.py:15:1: UP035 [*] Import from `collections.abc` instead: `Mapping` | 13 | Mapping) -14 | +14 | 15 | / from collections import Counter, \ 16 | | Mapping | |________________________________^ UP035 -17 | +17 | 18 | from collections import Counter, Mapping, Sequence | = help: Import from `collections.abc` @@ -157,10 +156,10 @@ UP035.py:15:1: UP035 [*] Import from `collections.abc` instead: `Mapping` UP035.py:18:1: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Sequence` | 16 | Mapping -17 | +17 | 18 | from collections import Counter, Mapping, Sequence | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -19 | +19 | 20 | from collections import Mapping as mapping, Counter | = help: Import from `collections.abc` @@ -179,10 +178,10 @@ UP035.py:18:1: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Sequ UP035.py:20:1: UP035 [*] Import from `collections.abc` instead: `Mapping` | 18 | from collections import Counter, Mapping, Sequence -19 | +19 | 20 | from collections import Mapping as mapping, Counter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -21 | +21 | 22 | if True: | = help: Import from `collections.abc` @@ -203,7 +202,7 @@ UP035.py:23:5: UP035 [*] Import from `collections.abc` instead: `Mapping` 22 | if True: 23 | from collections import Mapping, Counter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -24 | +24 | 25 | if True: | = help: Import from `collections.abc` @@ -225,7 +224,7 @@ UP035.py:28:5: UP035 [*] Import from `collections.abc` instead: `Mapping` 27 | pass 28 | from collections import Mapping, Counter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -29 | +29 | 30 | if True: from collections import Mapping | = help: Import from `collections.abc` @@ -244,10 +243,10 @@ UP035.py:28:5: UP035 [*] Import from `collections.abc` instead: `Mapping` UP035.py:30:10: UP035 [*] Import from `collections.abc` instead: `Mapping` | 28 | from collections import Mapping, Counter -29 | +29 | 30 | if True: from collections import Mapping | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -31 | +31 | 32 | import os | = help: Import from `collections.abc` @@ -285,15 +284,14 @@ UP035.py:33:1: UP035 [*] Import from `collections.abc` instead: `Mapping` UP035.py:37:5: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Callable` | 36 | if True: -37 | from collections import ( - | _____^ +37 | / from collections import ( 38 | | Mapping, 39 | | Callable, 40 | | Bad, 41 | | Good, 42 | | ) | |_____^ UP035 -43 | +43 | 44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager | = help: Import from `collections.abc` @@ -315,10 +313,10 @@ UP035.py:37:5: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Call UP035.py:44:1: UP035 [*] Import from `collections.abc` instead: `Callable` | 42 | ) -43 | +43 | 44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -45 | +45 | 46 | if True: from collections import ( | = help: Import from `collections.abc` @@ -337,10 +335,10 @@ UP035.py:44:1: UP035 [*] Import from `collections.abc` instead: `Callable` UP035.py:44:1: UP035 [*] Import from `collections` instead: `OrderedDict` | 42 | ) -43 | +43 | 44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -45 | +45 | 46 | if True: from collections import ( | = help: Import from `collections` @@ -359,10 +357,10 @@ UP035.py:44:1: UP035 [*] Import from `collections` instead: `OrderedDict` UP035.py:44:1: UP035 [*] Import from `re` instead: `Match`, `Pattern` | 42 | ) -43 | +43 | 44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -45 | +45 | 46 | if True: from collections import ( | = help: Import from `re` @@ -381,42 +379,42 @@ UP035.py:44:1: UP035 [*] Import from `re` instead: `Match`, `Pattern` UP035.py:44:1: UP035 `typing.List` is deprecated, use `list` instead | 42 | ) -43 | +43 | 44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -45 | +45 | 46 | if True: from collections import ( | UP035.py:44:1: UP035 `typing.AbstractSet` is deprecated, use `collections.abc.Set` instead | 42 | ) -43 | +43 | 44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -45 | +45 | 46 | if True: from collections import ( | UP035.py:44:1: UP035 `typing.ContextManager` is deprecated, use `contextlib.AbstractContextManager` instead | 42 | ) -43 | +43 | 44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -45 | +45 | 46 | if True: from collections import ( | UP035.py:46:10: UP035 Import from `collections.abc` instead: `Mapping` | 44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager -45 | +45 | 46 | if True: from collections import ( | __________^ 47 | | Mapping, Counter) | |_____________________^ UP035 -48 | +48 | 49 | # Bad imports from PYI027 that are now handled by PYI022 (UP035) | = help: Import from `collections.abc` @@ -1001,7 +999,7 @@ UP035.py:84:1: UP035 [*] Import from `typing` instead: `SupportsIndex` 83 | # UP035 on py312+ only 84 | from typing_extensions import SupportsIndex | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -85 | +85 | 86 | # UP035 on py312+ only | = help: Import from `typing` @@ -1021,7 +1019,7 @@ UP035.py:87:1: UP035 [*] Import from `typing` instead: `NamedTuple` 86 | # UP035 on py312+ only 87 | from typing_extensions import NamedTuple | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -88 | +88 | 89 | # UP035 on py312+ only: `typing_extensions` supports `frozen_default` (backported from 3.12). | = help: Import from `typing` @@ -1041,7 +1039,7 @@ UP035.py:90:1: UP035 [*] Import from `typing` instead: `dataclass_transform` 89 | # UP035 on py312+ only: `typing_extensions` supports `frozen_default` (backported from 3.12). 90 | from typing_extensions import dataclass_transform | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -91 | +91 | 92 | # UP035 | = help: Import from `typing` @@ -1061,7 +1059,7 @@ UP035.py:93:1: UP035 [*] Import from `enum` instead: `StrEnum` 92 | # UP035 93 | from backports.strenum import StrEnum | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -94 | +94 | 95 | # UP035 | = help: Import from `enum` @@ -1081,7 +1079,7 @@ UP035.py:96:1: UP035 [*] Import from `typing` instead: `override` 95 | # UP035 96 | from typing_extensions import override | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -97 | +97 | 98 | # UP035 | = help: Import from `typing` @@ -1101,7 +1099,7 @@ UP035.py:99:1: UP035 [*] Import from `collections.abc` instead: `Buffer` 98 | # UP035 99 | from typing_extensions import Buffer | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -100 | +100 | 101 | # UP035 | = help: Import from `collections.abc` @@ -1121,7 +1119,7 @@ UP035.py:102:1: UP035 [*] Import from `types` instead: `get_original_bases` 101 | # UP035 102 | from typing_extensions import get_original_bases | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -103 | +103 | 104 | # UP035 on py313+ only | = help: Import from `types` @@ -1141,7 +1139,7 @@ UP035.py:105:1: UP035 [*] Import from `typing` instead: `TypeVar` 104 | # UP035 on py313+ only 105 | from typing_extensions import TypeVar | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -106 | +106 | 107 | # UP035 on py313+ only | = help: Import from `typing` @@ -1161,7 +1159,7 @@ UP035.py:108:1: UP035 [*] Import from `types` instead: `CapsuleType` 107 | # UP035 on py313+ only 108 | from typing_extensions import CapsuleType | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -109 | +109 | 110 | # UP035 on py313+ only | = help: Import from `types` diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB110_FURB110.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB110_FURB110.py.snap index 476f8ae2224b3..cea81dcdd4c3c 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB110_FURB110.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB110_FURB110.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB110.py:1:5: FURB110 [*] Replace ternary `if` expression with `or` operator | 1 | z = x if x else y # FURB110 | ^^^^^^^^^^^^^ FURB110 -2 | +2 | 3 | z = x \ | = help: Replace with `or` operator @@ -21,12 +20,12 @@ FURB110.py:1:5: FURB110 [*] Replace ternary `if` expression with `or` operator FURB110.py:3:5: FURB110 [*] Replace ternary `if` expression with `or` operator | 1 | z = x if x else y # FURB110 -2 | +2 | 3 | z = x \ | _____^ 4 | | if x else y # FURB110 | |_______________^ FURB110 -5 | +5 | 6 | z = x if x \ | = help: Replace with `or` operator @@ -44,13 +43,13 @@ FURB110.py:3:5: FURB110 [*] Replace ternary `if` expression with `or` operator FURB110.py:6:5: FURB110 [*] Replace ternary `if` expression with `or` operator | 4 | if x else y # FURB110 - 5 | + 5 | 6 | z = x if x \ | _____^ 7 | | else \ 8 | | y # FURB110 | |_________^ FURB110 - 9 | + 9 | 10 | z = x() if x() else y() # FURB110 | = help: Replace with `or` operator @@ -70,10 +69,10 @@ FURB110.py:6:5: FURB110 [*] Replace ternary `if` expression with `or` operator FURB110.py:10:5: FURB110 [*] Replace ternary `if` expression with `or` operator | 8 | y # FURB110 - 9 | + 9 | 10 | z = x() if x() else y() # FURB110 | ^^^^^^^^^^^^^^^^^^^ FURB110 -11 | +11 | 12 | # FURB110 | = help: Replace with `or` operator @@ -100,7 +99,7 @@ FURB110.py:13:5: FURB110 [*] Replace ternary `if` expression with `or` operator 18 | | y 19 | | ) | |_^ FURB110 -20 | +20 | 21 | # FURB110 | = help: Replace with `or` operator @@ -123,8 +122,7 @@ FURB110.py:23:5: FURB110 [*] Replace ternary `if` expression with `or` operator | 21 | # FURB110 22 | z = ( -23 | x if ( - | _____^ +23 | / x if ( 24 | | # Test for x. 25 | | x 26 | | ) else ( @@ -154,8 +152,7 @@ FURB110.py:34:5: FURB110 [*] Replace ternary `if` expression with `or` operator | 32 | # FURB110 33 | z = ( -34 | x if - | _____^ +34 | / x if 35 | | # If true, use x. 36 | | x 37 | | # Otherwise, use y. @@ -185,8 +182,7 @@ FURB110.py:44:5: FURB110 [*] Replace ternary `if` expression with `or` operator | 42 | # FURB110 43 | z = ( -44 | x - | _____^ +44 | / x 45 | | if x 46 | | else y 47 | | if y > 0 diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB113_FURB113.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB113_FURB113.py.snap index 5ab20d9d4310c..401cf40ff61e0 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB113_FURB113.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB113_FURB113.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB113.py:23:1: FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly calling `nums.append()` | @@ -156,8 +155,7 @@ FURB113.py:69:5: FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly cal | 67 | if True: 68 | # FURB113 -69 | nums.append(1) - | _____^ +69 | / nums.append(1) 70 | | nums.append(2) | |__________________^ FURB113 | @@ -178,8 +176,7 @@ FURB113.py:75:5: FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly cal | 73 | if True: 74 | # FURB113 -75 | nums.append(1) - | _____^ +75 | / nums.append(1) 76 | | nums.append(2) | |__________________^ FURB113 77 | pass @@ -201,8 +198,7 @@ FURB113.py:82:5: FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly call | 80 | if True: 81 | # FURB113 -82 | nums.append(1) - | _____^ +82 | / nums.append(1) 83 | | nums2.append(1) 84 | | nums.append(2) 85 | | nums.append(3) @@ -214,8 +210,7 @@ FURB113.py:90:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly callin | 88 | def yes_one(x: list[int]): 89 | # FURB113 -90 | x.append(1) - | _____^ +90 | / x.append(1) 91 | | x.append(2) | |_______________^ FURB113 | @@ -236,8 +231,7 @@ FURB113.py:96:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly callin | 94 | def yes_two(x: List[int]): 95 | # FURB113 -96 | x.append(1) - | _____^ +96 | / x.append(1) 97 | | x.append(2) | |_______________^ FURB113 | @@ -258,8 +252,7 @@ FURB113.py:102:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calli | 100 | def yes_three(*, x: list[int]): 101 | # FURB113 -102 | x.append(1) - | _____^ +102 | / x.append(1) 103 | | x.append(2) | |_______________^ FURB113 | @@ -280,8 +273,7 @@ FURB113.py:108:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calli | 106 | def yes_four(x: list[int], /): 107 | # FURB113 -108 | x.append(1) - | _____^ +108 | / x.append(1) 109 | | x.append(2) | |_______________^ FURB113 | @@ -302,8 +294,7 @@ FURB113.py:114:5: FURB113 Use `x.extend((1, 2, 3))` instead of repeatedly callin | 112 | def yes_five(x: list[int], y: list[int]): 113 | # FURB113 -114 | x.append(1) - | _____^ +114 | / x.append(1) 115 | | x.append(2) 116 | | y.append(1) 117 | | x.append(3) @@ -315,8 +306,7 @@ FURB113.py:122:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calli | 120 | def yes_six(x: list): 121 | # FURB113 -122 | x.append(1) - | _____^ +122 | / x.append(1) 123 | | x.append(2) | |_______________^ FURB113 | @@ -337,8 +327,7 @@ FURB113.py:128:5: FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly cal | 126 | if True: 127 | # FURB113 -128 | nums.append(1) - | _____^ +128 | / nums.append(1) 129 | | # comment 130 | | nums.append(2) 131 | | # comment diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB154_FURB154.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB154_FURB154.py.snap index aa1be216fde57..cb55d4165e94b 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB154_FURB154.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB154_FURB154.py.snap @@ -1,12 +1,10 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB154.py:4:5: FURB154 [*] Use of repeated consecutive `global` | 3 | def f1(): -4 | global x - | _____^ +4 | / global x 5 | | global y | |____________^ FURB154 | @@ -26,8 +24,7 @@ FURB154.py:4:5: FURB154 [*] Use of repeated consecutive `global` FURB154.py:9:5: FURB154 [*] Use of repeated consecutive `global` | 8 | def f3(): - 9 | global x - | _____^ + 9 | / global x 10 | | global y 11 | | global z | |____________^ FURB154 @@ -49,8 +46,7 @@ FURB154.py:9:5: FURB154 [*] Use of repeated consecutive `global` FURB154.py:15:5: FURB154 [*] Use of repeated consecutive `global` | 14 | def f4(): -15 | global x - | _____^ +15 | / global x 16 | | global y | |____________^ FURB154 17 | pass @@ -73,8 +69,7 @@ FURB154.py:18:5: FURB154 [*] Use of repeated consecutive `global` | 16 | global y 17 | pass -18 | global x - | _____^ +18 | / global x 19 | | global y | |____________^ FURB154 | @@ -94,11 +89,10 @@ FURB154.py:18:5: FURB154 [*] Use of repeated consecutive `global` FURB154.py:26:9: FURB154 [*] Use of repeated consecutive `nonlocal` | 25 | def inner(): -26 | nonlocal x - | _________^ +26 | / nonlocal x 27 | | nonlocal y | |__________________^ FURB154 -28 | +28 | 29 | def inner2(): | = help: Merge `nonlocal` statements @@ -117,12 +111,11 @@ FURB154.py:26:9: FURB154 [*] Use of repeated consecutive `nonlocal` FURB154.py:30:9: FURB154 [*] Use of repeated consecutive `nonlocal` | 29 | def inner2(): -30 | nonlocal x - | _________^ +30 | / nonlocal x 31 | | nonlocal y 32 | | nonlocal z | |__________________^ FURB154 -33 | +33 | 34 | def inner3(): | = help: Merge `nonlocal` statements @@ -142,8 +135,7 @@ FURB154.py:30:9: FURB154 [*] Use of repeated consecutive `nonlocal` FURB154.py:35:9: FURB154 [*] Use of repeated consecutive `nonlocal` | 34 | def inner3(): -35 | nonlocal x - | _________^ +35 | / nonlocal x 36 | | nonlocal y | |__________________^ FURB154 37 | pass @@ -166,8 +158,7 @@ FURB154.py:38:9: FURB154 [*] Use of repeated consecutive `nonlocal` | 36 | nonlocal y 37 | pass -38 | nonlocal x - | _________^ +38 | / nonlocal x 39 | | nonlocal y | |__________________^ FURB154 | @@ -187,8 +178,7 @@ FURB154.py:38:9: FURB154 [*] Use of repeated consecutive `nonlocal` FURB154.py:46:9: FURB154 [*] Use of repeated consecutive `global` | 45 | def inner(): -46 | global w - | _________^ +46 | / global w 47 | | global x | |________________^ FURB154 48 | nonlocal y @@ -211,11 +201,10 @@ FURB154.py:48:9: FURB154 [*] Use of repeated consecutive `nonlocal` | 46 | global w 47 | global x -48 | nonlocal y - | _________^ +48 | / nonlocal y 49 | | nonlocal z | |__________________^ FURB154 -50 | +50 | 51 | def inner2(): | = help: Merge `nonlocal` statements @@ -235,8 +224,7 @@ FURB154.py:53:9: FURB154 [*] Use of repeated consecutive `nonlocal` | 51 | def inner2(): 52 | global x -53 | nonlocal y - | _________^ +53 | / nonlocal y 54 | | nonlocal z | |__________________^ FURB154 | @@ -256,8 +244,7 @@ FURB154.py:53:9: FURB154 [*] Use of repeated consecutive `nonlocal` FURB154.py:58:5: FURB154 [*] Use of repeated consecutive `global` | 57 | def f6(): -58 | global x, y, z - | _____^ +58 | / global x, y, z 59 | | global a, b, c 60 | | global d, e, f | |__________________^ FURB154 diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB156_FURB156.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB156_FURB156.py.snap index f9f12e934bddb..c11a67749126e 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB156_FURB156.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB156_FURB156.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- FURB156.py:3:5: FURB156 [*] Use of hardcoded string charset | 1 | # Errors -2 | +2 | 3 | _ = "0123456789" | ^^^^^^^^^^^^ FURB156 4 | _ = "01234567" @@ -174,7 +173,7 @@ FURB156.py:10:5: FURB156 [*] Use of hardcoded string charset 9 | _ = r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~""" 10 | _ = " \t\n\r\v\f" | ^^^^^^^^^^^^^ FURB156 -11 | +11 | 12 | _ = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c' | = help: Replace hardcoded charset with `string.whitespace` @@ -198,7 +197,7 @@ FURB156.py:10:5: FURB156 [*] Use of hardcoded string charset FURB156.py:12:5: FURB156 [*] Use of hardcoded string charset | 10 | _ = " \t\n\r\v\f" -11 | +11 | 12 | _ = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c' | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB156 13 | _ = ( @@ -226,8 +225,7 @@ FURB156.py:14:5: FURB156 [*] Use of hardcoded string charset | 12 | _ = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c' 13 | _ = ( -14 | '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&' - | _____^ +14 | / '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&' 15 | | "'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c" | |________________________________________________^ FURB156 16 | ) @@ -261,7 +259,7 @@ FURB156.py:17:8: FURB156 [*] Use of hardcoded string charset 18 | | "4567" 19 | | "89") | |___________^ FURB156 -20 | +20 | 21 | _ = ( | = help: Replace hardcoded charset with `string.digits` diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB188_FURB188.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB188_FURB188.py.snap index ad7888bf20cd5..4627dab5ecb45 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB188_FURB188.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB188_FURB188.py.snap @@ -4,11 +4,10 @@ source: crates/ruff_linter/src/rules/refurb/mod.rs FURB188.py:7:5: FURB188 [*] Prefer `str.removesuffix()` over conditionally replacing with slice. | 6 | def remove_extension_via_slice(filename: str) -> str: - 7 | if filename.endswith(".txt"): - | _____^ + 7 | / if filename.endswith(".txt"): 8 | | filename = filename[:-4] | |________________________________^ FURB188 - 9 | + 9 | 10 | return filename | = help: Use removesuffix instead of assignment conditional upon endswith. @@ -27,11 +26,10 @@ FURB188.py:7:5: FURB188 [*] Prefer `str.removesuffix()` over conditionally repla FURB188.py:14:5: FURB188 [*] Prefer `str.removesuffix()` over conditionally replacing with slice. | 13 | def remove_extension_via_slice_len(filename: str, extension: str) -> str: -14 | if filename.endswith(extension): - | _____^ +14 | / if filename.endswith(extension): 15 | | filename = filename[:-len(extension)] | |_____________________________________________^ FURB188 -16 | +16 | 17 | return filename | = help: Use removesuffix instead of assignment conditional upon endswith. @@ -122,10 +120,10 @@ FURB188.py:33:12: FURB188 [*] Prefer `str.removeprefix()` over conditionally rep FURB188.py:146:9: FURB188 [*] Prefer `str.removesuffix()` over conditionally replacing with slice. | 144 | SUFFIX = "suffix" -145 | +145 | 146 | x = foo.bar.baz[:-len(SUFFIX)] if foo.bar.baz.endswith(SUFFIX) else foo.bar.baz | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB188 -147 | +147 | 148 | def remove_prefix_comparable_literal_expr() -> None: | = help: Use removesuffix instead of ternary expression conditional upon endswith. @@ -145,7 +143,7 @@ FURB188.py:149:12: FURB188 [*] Prefer `str.removeprefix()` over conditionally re 148 | def remove_prefix_comparable_literal_expr() -> None: 149 | return ("abc" "def")[3:] if ("abc" "def").startswith("abc") else "abc" "def" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB188 -150 | +150 | 151 | def shadow_builtins(filename: str, extension: str) -> None: | = help: Use removeprefix instead of ternary expression conditional upon startswith. @@ -163,10 +161,10 @@ FURB188.py:149:12: FURB188 [*] Prefer `str.removeprefix()` over conditionally re FURB188.py:154:12: FURB188 [*] Prefer `str.removesuffix()` over conditionally replacing with slice. | 152 | from builtins import len as builtins_len -153 | +153 | 154 | return filename[:-builtins_len(extension)] if filename.endswith(extension) else filename | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB188 -155 | +155 | 156 | def okay_steps(): | = help: Use removesuffix instead of ternary expression conditional upon endswith. @@ -185,8 +183,7 @@ FURB188.py:158:5: FURB188 [*] Prefer `str.removeprefix()` over conditionally rep | 156 | def okay_steps(): 157 | text = "!x!y!z" -158 | if text.startswith("!"): - | _____^ +158 | / if text.startswith("!"): 159 | | text = text[1::1] | |_________________________^ FURB188 160 | if text.startswith("!"): @@ -209,8 +206,7 @@ FURB188.py:160:5: FURB188 [*] Prefer `str.removeprefix()` over conditionally rep | 158 | if text.startswith("!"): 159 | text = text[1::1] -160 | if text.startswith("!"): - | _____^ +160 | / if text.startswith("!"): 161 | | text = text[1::True] | |____________________________^ FURB188 162 | if text.startswith("!"): @@ -233,8 +229,7 @@ FURB188.py:162:5: FURB188 [*] Prefer `str.removeprefix()` over conditionally rep | 160 | if text.startswith("!"): 161 | text = text[1::True] -162 | if text.startswith("!"): - | _____^ +162 | / if text.startswith("!"): 163 | | text = text[1::None] | |____________________________^ FURB188 164 | print(text) @@ -256,8 +251,7 @@ FURB188.py:183:5: FURB188 [*] Prefer `str.removeprefix()` over conditionally rep | 181 | # with fix `text = text.removeprefix("ř")` 182 | text = "řetězec" -183 | if text.startswith("ř"): - | _____^ +183 | / if text.startswith("ř"): 184 | | text = text[1:] | |_______________________^ FURB188 | @@ -278,8 +272,7 @@ FURB188.py:190:5: FURB188 [*] Prefer `str.removeprefix()` over conditionally rep | 188 | # should be linted 189 | text = "\ud800\udc00heythere" -190 | if text.startswith("\ud800\udc00"): - | _____^ +190 | / if text.startswith("\ud800\udc00"): 191 | | text = text[2:] | |_______________________^ FURB188 192 | text = "\U00010000heythere" @@ -302,8 +295,7 @@ FURB188.py:193:5: FURB188 [*] Prefer `str.removeprefix()` over conditionally rep | 191 | text = text[2:] 192 | text = "\U00010000heythere" -193 | if text.startswith("\U00010000"): - | _____^ +193 | / if text.startswith("\U00010000"): 194 | | text = text[1:] | |_______________________^ FURB188 195 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF022_RUF022.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF022_RUF022.py.snap index bcc2be47a9512..f512d92a1d7ac 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF022_RUF022.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF022_RUF022.py.snap @@ -4,7 +4,7 @@ source: crates/ruff_linter/src/rules/ruff/mod.rs RUF022.py:5:11: RUF022 [*] `__all__` is not sorted | 3 | ################################################## -4 | +4 | 5 | __all__ = ["d", "c", "b", "a"] # a comment that is untouched | ^^^^^^^^^^^^^^^^^^^^ RUF022 6 | __all__ += ["foo", "bar", "antipasti"] @@ -47,7 +47,7 @@ RUF022.py:7:11: RUF022 [*] `__all__` is not sorted 6 | __all__ += ["foo", "bar", "antipasti"] 7 | __all__ = ("d", "c", "b", "a") | ^^^^^^^^^^^^^^^^^^^^ RUF022 -8 | +8 | 9 | # Quoting style is retained, | = help: Apply an isort-style sorting to `__all__` @@ -89,7 +89,7 @@ RUF022.py:14:18: RUF022 [*] `__all__` is not sorted 13 | # (but they are in multiline `__all__` definitions) 14 | __all__: tuple = ("b", "c", "a",) | ^^^^^^^^^^^^^^^^ RUF022 -15 | +15 | 16 | if bool(): | = help: Apply an isort-style sorting to `__all__` @@ -130,7 +130,7 @@ RUF022.py:19:16: RUF022 [*] `__all__` is not sorted 18 | else: 19 | __all__ += "foo3", "foo2", "foo1" # NB: an implicit tuple (without parens) | ^^^^^^^^^^^^^^^^^^^^^^ RUF022 -20 | +20 | 21 | __all__: list[str] = ["the", "three", "little", "pigs"] | = help: Apply an isort-style sorting to `__all__` @@ -148,10 +148,10 @@ RUF022.py:19:16: RUF022 [*] `__all__` is not sorted RUF022.py:21:22: RUF022 [*] `__all__` is not sorted | 19 | __all__ += "foo3", "foo2", "foo1" # NB: an implicit tuple (without parens) -20 | +20 | 21 | __all__: list[str] = ["the", "three", "little", "pigs"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF022 -22 | +22 | 23 | __all__ = ("parenthesized_item"), "in", ("an_unparenthesized_tuple") | = help: Apply an isort-style sorting to `__all__` @@ -169,7 +169,7 @@ RUF022.py:21:22: RUF022 [*] `__all__` is not sorted RUF022.py:23:11: RUF022 [*] `__all__` is not sorted | 21 | __all__: list[str] = ["the", "three", "little", "pigs"] -22 | +22 | 23 | __all__ = ("parenthesized_item"), "in", ("an_unparenthesized_tuple") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF022 24 | __all__.extend(["foo", "bar"]) @@ -233,7 +233,7 @@ RUF022.py:26:19: RUF022 [*] `__all__` is not sorted 25 | __all__.extend(("foo", "bar")) 26 | __all__.extend((((["foo", "bar"])))) | ^^^^^^^^^^^^^^ RUF022 -27 | +27 | 28 | #################################### | = help: Apply an isort-style sorting to `__all__` @@ -251,7 +251,7 @@ RUF022.py:26:19: RUF022 [*] `__all__` is not sorted RUF022.py:32:11: RUF022 [*] `__all__` is not sorted | 30 | #################################### -31 | +31 | 32 | __all__ = ( | ___________^ 33 | | "d0", @@ -261,7 +261,7 @@ RUF022.py:32:11: RUF022 [*] `__all__` is not sorted 37 | | "a0" 38 | | ) | |_^ RUF022 -39 | +39 | 40 | __all__ = [ | = help: Apply an isort-style sorting to `__all__` @@ -286,7 +286,7 @@ RUF022.py:32:11: RUF022 [*] `__all__` is not sorted RUF022.py:40:11: RUF022 [*] `__all__` is not sorted | 38 | ) -39 | +39 | 40 | __all__ = [ | ___________^ 41 | | "d", @@ -296,7 +296,7 @@ RUF022.py:40:11: RUF022 [*] `__all__` is not sorted 45 | | "a" 46 | | ] | |_^ RUF022 -47 | +47 | 48 | # we implement an "isort-style sort": | = help: Apply an isort-style sorting to `__all__` @@ -355,7 +355,7 @@ RUF022.py:54:11: RUF022 [*] `__all__` is not sorted 83 | | "weekday", 84 | | "weekheader"] | |_________________^ RUF022 -85 | +85 | 86 | ########################################## | = help: Apply an isort-style sorting to `__all__` @@ -447,7 +447,7 @@ RUF022.py:91:11: RUF022 [*] `__all__` is not sorted RUF022.py:101:11: RUF022 [*] `__all__` is not sorted | 99 | # comment7 -100 | +100 | 101 | __all__ = [ # comment0 | ___________^ 102 | | # comment1 @@ -458,7 +458,7 @@ RUF022.py:101:11: RUF022 [*] `__all__` is not sorted 107 | | # comment6 108 | | ] # comment7 | |_^ RUF022 -109 | +109 | 110 | __all__ = ["register", "lookup", "open", "EncodedFile", "BOM", "BOM_BE", | = help: Apply an isort-style sorting to `__all__` @@ -481,7 +481,7 @@ RUF022.py:101:11: RUF022 [*] `__all__` is not sorted RUF022.py:110:11: RUF022 [*] `__all__` is not sorted | 108 | ] # comment7 -109 | +109 | 110 | __all__ = ["register", "lookup", "open", "EncodedFile", "BOM", "BOM_BE", | ___________^ 111 | | "BOM_LE", "BOM32_BE", "BOM32_LE", "BOM64_BE", "BOM64_LE", @@ -498,7 +498,7 @@ RUF022.py:110:11: RUF022 [*] `__all__` is not sorted 122 | | "backslashreplace_errors", "namereplace_errors", 123 | | "register_error", "lookup_error"] | |____________________________________________^ RUF022 -124 | +124 | 125 | __all__: tuple[str, ...] = ( # a comment about the opening paren | = help: Apply an isort-style sorting to `__all__` @@ -574,7 +574,7 @@ RUF022.py:110:11: RUF022 [*] `__all__` is not sorted RUF022.py:125:28: RUF022 [*] `__all__` is not sorted | 123 | "register_error", "lookup_error"] -124 | +124 | 125 | __all__: tuple[str, ...] = ( # a comment about the opening paren | ____________________________^ 126 | | # multiline comment about "bbb" part 1 @@ -585,7 +585,7 @@ RUF022.py:125:28: RUF022 [*] `__all__` is not sorted 131 | | "aaa", 132 | | ) | |_^ RUF022 -133 | +133 | 134 | # we use natural sort for `__all__`, | = help: Apply an isort-style sorting to `__all__` @@ -619,7 +619,7 @@ RUF022.py:138:11: RUF022 [*] `__all__` is not sorted 142 | | "aadvark532" # the even longer whitespace span before this comment is retained 143 | | ) | |_^ RUF022 -144 | +144 | 145 | __all__.extend(( # comment0 | = help: Apply an isort-style sorting to `__all__` @@ -642,7 +642,7 @@ RUF022.py:138:11: RUF022 [*] `__all__` is not sorted RUF022.py:145:16: RUF022 [*] `__all__` is not sorted | 143 | ) -144 | +144 | 145 | __all__.extend(( # comment0 | ________________^ 146 | | # comment about foo @@ -652,7 +652,7 @@ RUF022.py:145:16: RUF022 [*] `__all__` is not sorted 150 | | # comment1 151 | | )) # comment2 | |_^ RUF022 -152 | +152 | 153 | __all__.extend( # comment0 | = help: Apply an isort-style sorting to `__all__` @@ -676,8 +676,7 @@ RUF022.py:155:5: RUF022 [*] `__all__` is not sorted | 153 | __all__.extend( # comment0 154 | # comment1 -155 | ( # comment2 - | _____^ +155 | / ( # comment2 156 | | # comment about foo 157 | | "foo", # comment about foo 158 | | # comment about bar @@ -707,7 +706,7 @@ RUF022.py:155:5: RUF022 [*] `__all__` is not sorted RUF022.py:164:16: RUF022 [*] `__all__` is not sorted | 162 | ) # comment2 -163 | +163 | 164 | __all__.extend([ # comment0 | ________________^ 165 | | # comment about foo @@ -717,7 +716,7 @@ RUF022.py:164:16: RUF022 [*] `__all__` is not sorted 169 | | # comment1 170 | | ]) # comment2 | |_^ RUF022 -171 | +171 | 172 | __all__.extend( # comment0 | = help: Apply an isort-style sorting to `__all__` @@ -741,8 +740,7 @@ RUF022.py:174:5: RUF022 [*] `__all__` is not sorted | 172 | __all__.extend( # comment0 173 | # comment1 -174 | [ # comment2 - | _____^ +174 | / [ # comment2 175 | | # comment about foo 176 | | "foo", # comment about foo 177 | | # comment about bar @@ -772,14 +770,14 @@ RUF022.py:174:5: RUF022 [*] `__all__` is not sorted RUF022.py:183:11: RUF022 [*] `__all__` is not sorted | 181 | ) # comment2 -182 | +182 | 183 | __all__ = ["Style", "Treeview", | ___________^ 184 | | # Extensions 185 | | "LabeledScale", "OptionMenu", 186 | | ] | |_^ RUF022 -187 | +187 | 188 | __all__ = ["Awaitable", "Coroutine", | = help: Apply an isort-style sorting to `__all__` @@ -804,13 +802,13 @@ RUF022.py:183:11: RUF022 [*] `__all__` is not sorted RUF022.py:188:11: RUF022 [*] `__all__` is not sorted | 186 | ] -187 | +187 | 188 | __all__ = ["Awaitable", "Coroutine", | ___________^ 189 | | "AsyncIterable", "AsyncIterator", "AsyncGenerator", 190 | | ] | |____________^ RUF022 -191 | +191 | 192 | __all__ = [ | = help: Apply an isort-style sorting to `__all__` @@ -836,7 +834,7 @@ RUF022.py:188:11: RUF022 [*] `__all__` is not sorted RUF022.py:192:11: RUF022 [*] `__all__` is not sorted | 190 | ] -191 | +191 | 192 | __all__ = [ | ___________^ 193 | | "foo", @@ -844,7 +842,7 @@ RUF022.py:192:11: RUF022 [*] `__all__` is not sorted 195 | | "baz", 196 | | ] | |_____^ RUF022 -197 | +197 | 198 | ######################################################################### | = help: Apply an isort-style sorting to `__all__` @@ -864,7 +862,7 @@ RUF022.py:192:11: RUF022 [*] `__all__` is not sorted RUF022.py:204:11: RUF022 `__all__` is not sorted | 202 | ######################################################################### -203 | +203 | 204 | __all__ = ( | ___________^ 205 | | "look", @@ -873,7 +871,7 @@ RUF022.py:204:11: RUF022 `__all__` is not sorted 208 | | ), 209 | | ) | |_^ RUF022 -210 | +210 | 211 | __all__ = ( | = help: Apply an isort-style sorting to `__all__` @@ -881,7 +879,7 @@ RUF022.py:204:11: RUF022 `__all__` is not sorted RUF022.py:211:11: RUF022 `__all__` is not sorted | 209 | ) -210 | +210 | 211 | __all__ = ( | ___________^ 212 | | "b", @@ -891,7 +889,7 @@ RUF022.py:211:11: RUF022 `__all__` is not sorted 216 | | "a" 217 | | ) | |_^ RUF022 -218 | +218 | 219 | __all__ = ("don't" "care" "about", "__all__" "with", "concatenated" "strings") | = help: Apply an isort-style sorting to `__all__` @@ -899,10 +897,10 @@ RUF022.py:211:11: RUF022 `__all__` is not sorted RUF022.py:219:11: RUF022 `__all__` is not sorted | 217 | ) -218 | +218 | 219 | __all__ = ("don't" "care" "about", "__all__" "with", "concatenated" "strings") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF022 -220 | +220 | 221 | ############################################################ | = help: Apply an isort-style sorting to `__all__` @@ -910,13 +908,13 @@ RUF022.py:219:11: RUF022 `__all__` is not sorted RUF022.py:225:11: RUF022 [*] `__all__` is not sorted | 223 | ############################################################ -224 | +224 | 225 | __all__ = ( | ___________^ 226 | | "loads", 227 | | "dumps",) | |_____________^ RUF022 -228 | +228 | 229 | __all__ = [ | = help: Apply an isort-style sorting to `__all__` @@ -936,13 +934,13 @@ RUF022.py:225:11: RUF022 [*] `__all__` is not sorted RUF022.py:229:11: RUF022 [*] `__all__` is not sorted | 227 | "dumps",) -228 | +228 | 229 | __all__ = [ | ___________^ 230 | | "loads", 231 | | "dumps" , ] | |_________________________^ RUF022 -232 | +232 | 233 | __all__ = ['xp', 'yp', | = help: Apply an isort-style sorting to `__all__` @@ -962,19 +960,19 @@ RUF022.py:229:11: RUF022 [*] `__all__` is not sorted RUF022.py:233:11: RUF022 [*] `__all__` is not sorted | 231 | "dumps" , ] -232 | +232 | 233 | __all__ = ['xp', 'yp', | ___________^ 234 | | 'canvas' -235 | | +235 | | 236 | | # very strangely placed comment -237 | | +237 | | 238 | | , -239 | | +239 | | 240 | | # another strangely placed comment 241 | | ] | |_________________^ RUF022 -242 | +242 | 243 | __all__ = ( | = help: Apply an isort-style sorting to `__all__` @@ -996,7 +994,7 @@ RUF022.py:233:11: RUF022 [*] `__all__` is not sorted RUF022.py:243:11: RUF022 [*] `__all__` is not sorted | 241 | ] -242 | +242 | 243 | __all__ = ( | ___________^ 244 | | "foo" @@ -1008,7 +1006,7 @@ RUF022.py:243:11: RUF022 [*] `__all__` is not sorted 250 | | , 251 | | ) | |_^ RUF022 -252 | +252 | 253 | __all__ = ( # comment about the opening paren | = help: Apply an isort-style sorting to `__all__` @@ -1031,7 +1029,7 @@ RUF022.py:243:11: RUF022 [*] `__all__` is not sorted RUF022.py:253:11: RUF022 [*] `__all__` is not sorted | 251 | ) -252 | +252 | 253 | __all__ = ( # comment about the opening paren | ___________^ 254 | | # multiline strange comment 0a @@ -1050,7 +1048,7 @@ RUF022.py:253:11: RUF022 [*] `__all__` is not sorted 267 | | # strange multiline comment 3b 268 | | ) # comment about the closing paren | |_^ RUF022 -269 | +269 | 270 | ################################### | = help: Apply an isort-style sorting to `__all__` diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF026_RUF026.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF026_RUF026.py.snap index 6e40ef428ee8d..aa55a482043a0 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF026_RUF026.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF026_RUF026.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF026.py:11:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` | @@ -95,7 +94,7 @@ RUF026.py:27:5: RUF026 [*] `default_factory` is a positional-only argument to `d RUF026.py:34:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` | 32 | pass -33 | +33 | 34 | defaultdict(default_factory=foo) # RUF026 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF026 | @@ -132,7 +131,7 @@ RUF026.py:38:5: RUF026 [*] `default_factory` is a positional-only argument to `d RUF026.py:44:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` | 42 | from collections import deque -43 | +43 | 44 | defaultdict(default_factory=deque) # RUF026 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF026 | @@ -151,7 +150,7 @@ RUF026.py:44:5: RUF026 [*] `default_factory` is a positional-only argument to `d RUF026.py:52:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` | 50 | pass -51 | +51 | 52 | defaultdict(default_factory=MyCallable()) # RUF026 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF026 | @@ -224,8 +223,7 @@ RUF026.py:64:5: RUF026 [*] `default_factory` is a positional-only argument to `d RUF026.py:68:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` | 67 | def func(): -68 | defaultdict( - | _____^ +68 | / defaultdict( 69 | | member=1, 70 | | default_factory=tuple, 71 | | ) # RUF026 @@ -247,8 +245,7 @@ RUF026.py:68:5: RUF026 [*] `default_factory` is a positional-only argument to `d RUF026.py:75:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` | 74 | def func(): -75 | defaultdict( - | _____^ +75 | / defaultdict( 76 | | default_factory=tuple, 77 | | member=1, 78 | | ) # RUF026 diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF051_RUF051.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF051_RUF051.py.snap index cf940805e5c14..d164c38b8cb03 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF051_RUF051.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF051_RUF051.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF051.py:8:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` | 7 | if k in d: # Bare name 8 | del d[k] | ^^^^^^^^ RUF051 - 9 | + 9 | 10 | if '' in d: # String | = help: Replace `if` statement with `.pop(..., None)` @@ -28,7 +27,7 @@ RUF051.py:11:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 10 | if '' in d: # String 11 | del d[""] # Different quotes | ^^^^^^^^^ RUF051 -12 | +12 | 13 | if b"" in d: # Bytes | = help: Replace `if` statement with `.pop(..., None)` @@ -47,12 +46,11 @@ RUF051.py:11:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d RUF051.py:14:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` | 13 | if b"" in d: # Bytes -14 | del d[ # Multiline slice - | _____^ +14 | / del d[ # Multiline slice 15 | | b'''''' # Triple quotes 16 | | ] | |_____^ RUF051 -17 | +17 | 18 | if 0 in d: del d[0] # Single-line statement | = help: Replace `if` statement with `.pop(..., None)` @@ -73,10 +71,10 @@ RUF051.py:14:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d RUF051.py:18:12: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` | 16 | ] -17 | +17 | 18 | if 0 in d: del d[0] # Single-line statement | ^^^^^^^^ RUF051 -19 | +19 | 20 | if 3j in d: # Complex | = help: Replace `if` statement with `.pop(..., None)` @@ -96,7 +94,7 @@ RUF051.py:21:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 20 | if 3j in d: # Complex 21 | del d[3j] | ^^^^^^^^^ RUF051 -22 | +22 | 23 | if 0.1234 in d: # Float | = help: Replace `if` statement with `.pop(..., None)` @@ -117,7 +115,7 @@ RUF051.py:24:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 23 | if 0.1234 in d: # Float 24 | del d[.1_2_3_4] # Number separators and shorthand syntax | ^^^^^^^^^^^^^^^ RUF051 -25 | +25 | 26 | if True in d: # True | = help: Replace `if` statement with `.pop(..., None)` @@ -138,7 +136,7 @@ RUF051.py:27:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 26 | if True in d: # True 27 | del d[True] | ^^^^^^^^^^^ RUF051 -28 | +28 | 29 | if False in d: # False | = help: Replace `if` statement with `.pop(..., None)` @@ -159,7 +157,7 @@ RUF051.py:30:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 29 | if False in d: # False 30 | del d[False] | ^^^^^^^^^^^^ RUF051 -31 | +31 | 32 | if None in d: # None | = help: Replace `if` statement with `.pop(..., None)` @@ -178,13 +176,12 @@ RUF051.py:30:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d RUF051.py:33:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` | 32 | if None in d: # None -33 | del d[ - | _____^ +33 | / del d[ 34 | | # Comment in the middle 35 | | None 36 | | ] | |_____^ RUF051 -37 | +37 | 38 | if ... in d: # Ellipsis | = help: Replace `if` statement with `.pop(..., None)` @@ -206,12 +203,11 @@ RUF051.py:33:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d RUF051.py:39:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` | 38 | if ... in d: # Ellipsis -39 | del d[ - | _____^ +39 | / del d[ 40 | | # Comment in the middle, indented 41 | | ...] | |____________^ RUF051 -42 | +42 | 43 | if "a" "bc" in d: # String concatenation | = help: Replace `if` statement with `.pop(..., None)` @@ -234,7 +230,7 @@ RUF051.py:44:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 43 | if "a" "bc" in d: # String concatenation 44 | del d['abc'] | ^^^^^^^^^^^^ RUF051 -45 | +45 | 46 | if r"\foo" in d: # Raw string | = help: Replace `if` statement with `.pop(..., None)` @@ -255,7 +251,7 @@ RUF051.py:47:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 46 | if r"\foo" in d: # Raw string 47 | del d['\\foo'] | ^^^^^^^^^^^^^^ RUF051 -48 | +48 | 49 | if b'yt' b'es' in d: # Bytes concatenation | = help: Replace `if` statement with `.pop(..., None)` @@ -276,7 +272,7 @@ RUF051.py:50:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 49 | if b'yt' b'es' in d: # Bytes concatenation 50 | del d[rb"""ytes"""] # Raw bytes | ^^^^^^^^^^^^^^^^^^^ RUF051 -51 | +51 | 52 | if k in d: | = help: Replace `if` statement with `.pop(..., None)` @@ -298,7 +294,7 @@ RUF051.py:54:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 53 | # comment that gets dropped 54 | del d[k] | ^^^^^^^^ RUF051 -55 | +55 | 56 | ### Safely fixable | = help: Replace `if` statement with `.pop(..., None)` @@ -320,7 +316,7 @@ RUF051.py:59:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 58 | if k in d: 59 | del d[k] | ^^^^^^^^ RUF051 -60 | +60 | 61 | if '' in d: | = help: Replace `if` statement with `.pop(..., None)` @@ -341,7 +337,7 @@ RUF051.py:62:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 61 | if '' in d: 62 | del d[""] | ^^^^^^^^^ RUF051 -63 | +63 | 64 | if b"" in d: | = help: Replace `if` statement with `.pop(..., None)` @@ -360,12 +356,11 @@ RUF051.py:62:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d RUF051.py:65:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` | 64 | if b"" in d: -65 | del d[ - | _____^ +65 | / del d[ 66 | | b'''''' 67 | | ] | |_____^ RUF051 -68 | +68 | 69 | if 0 in d: del d[0] | = help: Replace `if` statement with `.pop(..., None)` @@ -386,10 +381,10 @@ RUF051.py:65:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d RUF051.py:69:12: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` | 67 | ] -68 | +68 | 69 | if 0 in d: del d[0] | ^^^^^^^^ RUF051 -70 | +70 | 71 | if 3j in d: | = help: Replace `if` statement with `.pop(..., None)` @@ -409,7 +404,7 @@ RUF051.py:72:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 71 | if 3j in d: 72 | del d[3j] | ^^^^^^^^^ RUF051 -73 | +73 | 74 | if 0.1234 in d: | = help: Replace `if` statement with `.pop(..., None)` @@ -430,7 +425,7 @@ RUF051.py:75:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 74 | if 0.1234 in d: 75 | del d[.1_2_3_4] | ^^^^^^^^^^^^^^^ RUF051 -76 | +76 | 77 | if True in d: | = help: Replace `if` statement with `.pop(..., None)` @@ -451,7 +446,7 @@ RUF051.py:78:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 77 | if True in d: 78 | del d[True] | ^^^^^^^^^^^ RUF051 -79 | +79 | 80 | if False in d: | = help: Replace `if` statement with `.pop(..., None)` @@ -472,7 +467,7 @@ RUF051.py:81:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 80 | if False in d: 81 | del d[False] | ^^^^^^^^^^^^ RUF051 -82 | +82 | 83 | if None in d: | = help: Replace `if` statement with `.pop(..., None)` @@ -491,12 +486,11 @@ RUF051.py:81:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d RUF051.py:84:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` | 83 | if None in d: -84 | del d[ - | _____^ +84 | / del d[ 85 | | None 86 | | ] | |_____^ RUF051 -87 | +87 | 88 | if ... in d: | = help: Replace `if` statement with `.pop(..., None)` @@ -517,11 +511,10 @@ RUF051.py:84:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d RUF051.py:89:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` | 88 | if ... in d: -89 | del d[ - | _____^ +89 | / del d[ 90 | | ...] | |____________^ RUF051 -91 | +91 | 92 | if "a" "bc" in d: | = help: Replace `if` statement with `.pop(..., None)` @@ -543,7 +536,7 @@ RUF051.py:93:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 92 | if "a" "bc" in d: 93 | del d['abc'] | ^^^^^^^^^^^^ RUF051 -94 | +94 | 95 | if r"\foo" in d: | = help: Replace `if` statement with `.pop(..., None)` @@ -564,7 +557,7 @@ RUF051.py:96:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 95 | if r"\foo" in d: 96 | del d['\\foo'] | ^^^^^^^^^^^^^^ RUF051 -97 | +97 | 98 | if b'yt' b'es' in d: | = help: Replace `if` statement with `.pop(..., None)` diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__prefer_parentheses_getitem_tuple.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__prefer_parentheses_getitem_tuple.snap index ce4161086e9ef..3ea279c548de9 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__prefer_parentheses_getitem_tuple.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__prefer_parentheses_getitem_tuple.snap @@ -1,13 +1,11 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- RUF031_prefer_parens.py:8:5: RUF031 [*] Use parentheses for tuples in subscripts | 6 | )] 7 | d[ - 8 | 1, - | _____^ + 8 | / 1, 9 | | 2 | |_____^ RUF031 10 | ] @@ -96,7 +94,7 @@ RUF031_prefer_parens.py:21:3: RUF031 [*] Use parentheses for tuples in subscript 20 | e[((1,2),(3,4))] 21 | e[(1,2),(3,4)] | ^^^^^^^^^^^ RUF031 -22 | +22 | 23 | token_features[ | = help: Parenthesize tuple diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF039_RUF039_concat.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF039_RUF039_concat.py.snap index e6bcb2e0e7eef..77e805efd512c 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF039_RUF039_concat.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF039_RUF039_concat.py.snap @@ -46,8 +46,7 @@ RUF039_concat.py:12:5: RUF039 [*] First argument to `re.findall()` is not raw st | 10 | multiline 11 | ''' -12 | """ - | _____^ +12 | / """ 13 | | concatenation 14 | | """ | |_______^ RUF039 @@ -277,8 +276,7 @@ RUF039_concat.py:52:5: RUF039 [*] First argument to `regex.findall()` is not raw | 50 | multiline 51 | ''' -52 | """ - | _____^ +52 | / """ 53 | | concatenation 54 | | """ | |_______^ RUF039 diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__type-check-without-type-error_TRY004.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__type-check-without-type-error_TRY004.py.snap index 77ebf52e85c09..1400f13f981b1 100644 --- a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__type-check-without-type-error_TRY004.py.snap +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__type-check-without-type-error_TRY004.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/tryceratops/mod.rs -snapshot_kind: text --- TRY004.py:12:9: TRY004 Prefer `TypeError` exception for invalid type | @@ -94,8 +93,7 @@ TRY004.py:95:9: TRY004 Prefer `TypeError` exception for invalid type | 93 | # should be typeerror 94 | # not multiline is on purpose for fix -95 | raise MemoryError( - | _________^ +95 | / raise MemoryError( 96 | | "..." 97 | | ) | |_________^ TRY004 diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__useless-try-except_TRY203.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__useless-try-except_TRY203.py.snap index 6192e3759f20b..9f150810bf46d 100644 --- a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__useless-try-except_TRY203.py.snap +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__useless-try-except_TRY203.py.snap @@ -1,16 +1,14 @@ --- source: crates/ruff_linter/src/rules/tryceratops/mod.rs -snapshot_kind: text --- TRY203.py:12:5: TRY203 Remove exception handler; error is immediately re-raised | 10 | try: 11 | process() -12 | except Exception: - | _____^ +12 | / except Exception: 13 | | raise | |_____________^ TRY203 -14 | +14 | 15 | def bad(): | @@ -18,12 +16,11 @@ TRY203.py:18:5: TRY203 Remove exception handler; error is immediately re-raised | 16 | try: 17 | process() -18 | except Exception: - | _____^ +18 | / except Exception: 19 | | raise 20 | | print("this code is pointless!") | |________________________________________^ TRY203 -21 | +21 | 22 | def bad(): | @@ -31,12 +28,11 @@ TRY203.py:25:5: TRY203 Remove exception handler; error is immediately re-raised | 23 | try: 24 | process() -25 | except: - | _____^ +25 | / except: 26 | | # I am a comment, not a statement! 27 | | raise | |_____________^ TRY203 -28 | +28 | 29 | def bad(): | @@ -44,11 +40,10 @@ TRY203.py:32:5: TRY203 Remove exception handler; error is immediately re-raised | 30 | try: 31 | process() -32 | except Exception: - | _____^ +32 | / except Exception: 33 | | raise | |_____________^ TRY203 -34 | +34 | 35 | def bad(): | @@ -56,11 +51,10 @@ TRY203.py:38:5: TRY203 Remove exception handler; error is immediately re-raised | 36 | try: 37 | process() -38 | except Exception as e: - | _____^ +38 | / except Exception as e: 39 | | raise | |_____________^ TRY203 -40 | +40 | 41 | def bad(): | @@ -68,11 +62,10 @@ TRY203.py:44:5: TRY203 Remove exception handler; error is immediately re-raised | 42 | try: 43 | process() -44 | except Exception as e: - | _____^ +44 | / except Exception as e: 45 | | raise e | |_______________^ TRY203 -46 | +46 | 47 | def bad(): | @@ -80,8 +73,7 @@ TRY203.py:50:5: TRY203 Remove exception handler; error is immediately re-raised | 48 | try: 49 | process() -50 | except MyException: - | _____^ +50 | / except MyException: 51 | | raise | |_____________^ TRY203 52 | except Exception: @@ -92,11 +84,10 @@ TRY203.py:52:5: TRY203 Remove exception handler; error is immediately re-raised | 50 | except MyException: 51 | raise -52 | except Exception: - | _____^ +52 | / except Exception: 53 | | raise | |_____________^ TRY203 -54 | +54 | 55 | def bad(): | @@ -104,8 +95,7 @@ TRY203.py:58:5: TRY203 Remove exception handler; error is immediately re-raised | 56 | try: 57 | process() -58 | except MyException as e: - | _____^ +58 | / except MyException as e: 59 | | raise e | |_______________^ TRY203 60 | except Exception as e: @@ -116,11 +106,10 @@ TRY203.py:60:5: TRY203 Remove exception handler; error is immediately re-raised | 58 | except MyException as e: 59 | raise e -60 | except Exception as e: - | _____^ +60 | / except Exception as e: 61 | | raise e | |_______________^ TRY203 -62 | +62 | 63 | def bad(): | @@ -128,8 +117,7 @@ TRY203.py:66:5: TRY203 Remove exception handler; error is immediately re-raised | 64 | try: 65 | process() -66 | except MyException as ex: - | _____^ +66 | / except MyException as ex: 67 | | raise ex | |________________^ TRY203 68 | except Exception as e: @@ -140,10 +128,9 @@ TRY203.py:68:5: TRY203 Remove exception handler; error is immediately re-raised | 66 | except MyException as ex: 67 | raise ex -68 | except Exception as e: - | _____^ +68 | / except Exception as e: 69 | | raise e | |_______________^ TRY203 -70 | +70 | 71 | def fine(): | From a97e262b8147269d0315e1e0f751ecd3652370c1 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Tue, 7 Jan 2025 14:16:46 -0500 Subject: [PATCH 08/18] test: update snapshots with missing `^` The previous rendering just seems wrong in that a `^` is omitted. The new version of `annotate-snippets` seems to get this right. I checked a pseudo random sample of these, and it seems to only happen when the position pointed at a line terminator. --- ...rules__flake8_commas__tests__COM81.py.snap | 127 +++++++++--------- ...s__pycodestyle__tests__W292_W292_0.py.snap | 3 +- ..._tests__PLE2512_invalid_characters.py.snap | 17 ++- ..._tests__PLE2514_invalid_characters.py.snap | Bin 827 -> 808 bytes ..._tests__PLE2515_invalid_characters.py.snap | 27 ++-- ...tests__PLR0202_no_method_decorator.py.snap | 7 +- ...tests__PLR0203_no_method_decorator.py.snap | 9 +- ...@expressions__attribute__no_member.py.snap | 5 +- ...ons__dict__missing_closing_brace_0.py.snap | 7 +- ...ons__dict__missing_closing_brace_1.py.snap | 5 +- ...s__list__missing_closing_bracket_0.py.snap | 5 +- ...s__list__missing_closing_bracket_1.py.snap | 5 +- ...s__list__missing_closing_bracket_2.py.snap | 5 +- ...sions__named__missing_expression_0.py.snap | 7 +- ...sions__named__missing_expression_1.py.snap | 5 +- ...sions__named__missing_expression_2.py.snap | 7 +- ...sions__named__missing_expression_3.py.snap | 5 +- ...ressions__parenthesized__generator.py.snap | 3 +- ...nthesized__missing_closing_paren_0.py.snap | 5 +- ...nthesized__missing_closing_paren_1.py.snap | 5 +- ...nthesized__missing_closing_paren_2.py.snap | 5 +- ...set__missing_closing_curly_brace_0.py.snap | 5 +- ...set__missing_closing_curly_brace_1.py.snap | 5 +- ...set__missing_closing_curly_brace_2.py.snap | 5 +- ...sions__subscript__unclosed_slice_0.py.snap | 5 +- ...sions__subscript__unclosed_slice_1.py.snap | 7 +- ...id_syntax@f_string_unclosed_lbrace.py.snap | 17 +-- ...y_concatenated_unterminated_string.py.snap | 3 +- ...ated_unterminated_string_multiline.py.snap | 3 +- ...nvalid_syntax@re_lex_logical_token.py.snap | 11 +- ...yntax@re_lex_logical_token_mac_eol.py.snap | 3 +- ...re_lexing__triple_quoted_fstring_1.py.snap | 7 +- ...nts__with__unclosed_ambiguous_lpar.py.snap | 7 +- ..._with__unclosed_ambiguous_lpar_eof.py.snap | 3 +- ...erminated_fstring_newline_recovery.py.snap | 9 +- 35 files changed, 161 insertions(+), 193 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81.py.snap b/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81.py.snap index 898a3b5f1a7c9..56628a26d864c 100644 --- a/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81.py.snap +++ b/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_commas/mod.rs -snapshot_kind: text --- COM81.py:4:18: COM812 [*] Trailing comma missing | 2 | bad_function_call( 3 | param1='test', 4 | param2='test' - | COM812 + | ^ COM812 5 | ) 6 | # ==> bad_list.py <== | @@ -28,7 +27,7 @@ COM81.py:10:6: COM812 [*] Trailing comma missing 8 | 1, 9 | 2, 10 | 3 - | COM812 + | ^ COM812 11 | ] | = help: Add trailing comma @@ -48,7 +47,7 @@ COM81.py:16:6: COM812 [*] Trailing comma missing 14 | 1, 15 | 2, 16 | 3 - | COM812 + | ^ COM812 17 | # still needs a comma! 18 | ] | @@ -69,7 +68,7 @@ COM81.py:23:6: COM812 [*] Trailing comma missing 21 | 1, 22 | 2, 23 | 3 - | COM812 + | ^ COM812 | = help: Add trailing comma @@ -86,30 +85,30 @@ COM81.py:23:6: COM812 [*] Trailing comma missing COM81.py:36:8: COM818 Trailing comma on bare tuple prohibited | 34 | foo = (1,) -35 | +35 | 36 | foo = 1, | ^ COM818 -37 | +37 | 38 | bar = 1; foo = bar, | COM81.py:38:19: COM818 Trailing comma on bare tuple prohibited | 36 | foo = 1, -37 | +37 | 38 | bar = 1; foo = bar, | ^ COM818 -39 | +39 | 40 | foo = ( | COM81.py:45:8: COM818 Trailing comma on bare tuple prohibited | 43 | ) -44 | +44 | 45 | foo = 3, | ^ COM818 -46 | +46 | 47 | class A(object): | @@ -125,20 +124,20 @@ COM81.py:49:10: COM818 Trailing comma on bare tuple prohibited COM81.py:56:32: COM818 Trailing comma on bare tuple prohibited | 54 | from foo import bar, baz -55 | +55 | 56 | group_by = function_call('arg'), | ^ COM818 -57 | +57 | 58 | group_by = ('foobar' * 3), | COM81.py:58:26: COM818 Trailing comma on bare tuple prohibited | 56 | group_by = function_call('arg'), -57 | +57 | 58 | group_by = ('foobar' * 3), | ^ COM818 -59 | +59 | 60 | def foo(): | @@ -147,7 +146,7 @@ COM81.py:61:17: COM818 Trailing comma on bare tuple prohibited 60 | def foo(): 61 | return False, | ^ COM818 -62 | +62 | 63 | # ==> callable_before_parenth_form.py <== | @@ -155,7 +154,7 @@ COM81.py:70:8: COM812 [*] Trailing comma missing | 69 | {'foo': foo}['foo']( 70 | bar - | COM812 + | ^ COM812 71 | ) | = help: Add trailing comma @@ -174,7 +173,7 @@ COM81.py:78:8: COM812 [*] Trailing comma missing | 77 | (foo)( 78 | bar - | COM812 + | ^ COM812 79 | ) | = help: Add trailing comma @@ -193,7 +192,7 @@ COM81.py:86:8: COM812 [*] Trailing comma missing | 85 | [foo][0]( 86 | bar - | COM812 + | ^ COM812 87 | ) | = help: Add trailing comma @@ -213,7 +212,7 @@ COM81.py:152:6: COM812 [*] Trailing comma missing 150 | # ==> keyword_before_parenth_form/base_bad.py <== 151 | from x import ( 152 | y - | COM812 + | ^ COM812 153 | ) | = help: Add trailing comma @@ -233,7 +232,7 @@ COM81.py:158:11: COM812 [*] Trailing comma missing 156 | SyntaxWarning, 157 | ThrownHere, 158 | Anyway - | COM812 + | ^ COM812 159 | ) | = help: Add trailing comma @@ -253,7 +252,7 @@ COM81.py:293:15: COM812 [*] Trailing comma missing 291 | # ==> multiline_bad_dict.py <== 292 | multiline_bad_dict = { 293 | "bad": 123 - | COM812 + | ^ COM812 294 | } 295 | # ==> multiline_bad_function_def.py <== | @@ -274,7 +273,7 @@ COM81.py:304:14: COM812 [*] Trailing comma missing 302 | def func_bad( 303 | a = 3, 304 | b = 2 - | COM812 + | ^ COM812 305 | ): 306 | pass | @@ -295,7 +294,7 @@ COM81.py:310:14: COM812 [*] Trailing comma missing 308 | # ==> multiline_bad_function_one_param.py <== 309 | def func( 310 | a = 3 - | COM812 + | ^ COM812 311 | ): 312 | pass | @@ -315,7 +314,7 @@ COM81.py:316:10: COM812 [*] Trailing comma missing | 315 | func( 316 | a = 3 - | COM812 + | ^ COM812 317 | ) | = help: Add trailing comma @@ -335,7 +334,7 @@ COM81.py:322:15: COM812 [*] Trailing comma missing 320 | multiline_bad_or_dict = { 321 | "good": True or False, 322 | "bad": 123 - | COM812 + | ^ COM812 323 | } | = help: Add trailing comma @@ -355,7 +354,7 @@ COM81.py:368:15: COM812 [*] Trailing comma missing 366 | multiline_index_access[ 367 | "probably fine", 368 | "not good" - | COM812 + | ^ COM812 369 | ] | = help: Add trailing comma @@ -375,7 +374,7 @@ COM81.py:375:15: COM812 [*] Trailing comma missing 373 | "fine", 374 | : 375 | "not good" - | COM812 + | ^ COM812 376 | ] | = help: Add trailing comma @@ -395,7 +394,7 @@ COM81.py:404:15: COM812 [*] Trailing comma missing 402 | "fine" 403 | : 404 | "not fine" - | COM812 + | ^ COM812 405 | ] | = help: Add trailing comma @@ -415,7 +414,7 @@ COM81.py:432:15: COM812 [*] Trailing comma missing 430 | : 431 | "fine", 432 | "not fine" - | COM812 + | ^ COM812 433 | ] | = help: Add trailing comma @@ -435,7 +434,7 @@ COM81.py:485:21: COM819 [*] Trailing comma prohibited 484 | # ==> prohibited.py <== 485 | foo = ['a', 'b', 'c',] | ^ COM819 -486 | +486 | 487 | bar = { a: b,} | = help: Remove trailing comma @@ -453,10 +452,10 @@ COM81.py:485:21: COM819 [*] Trailing comma prohibited COM81.py:487:13: COM819 [*] Trailing comma prohibited | 485 | foo = ['a', 'b', 'c',] -486 | +486 | 487 | bar = { a: b,} | ^ COM819 -488 | +488 | 489 | def bah(ham, spam,): | = help: Remove trailing comma @@ -474,7 +473,7 @@ COM81.py:487:13: COM819 [*] Trailing comma prohibited COM81.py:489:18: COM819 [*] Trailing comma prohibited | 487 | bar = { a: b,} -488 | +488 | 489 | def bah(ham, spam,): | ^ COM819 490 | pass @@ -494,10 +493,10 @@ COM81.py:489:18: COM819 [*] Trailing comma prohibited COM81.py:494:6: COM819 [*] Trailing comma prohibited | 492 | (0,) -493 | +493 | 494 | (0, 1,) | ^ COM819 -495 | +495 | 496 | foo = ['a', 'b', 'c', ] | = help: Remove trailing comma @@ -515,10 +514,10 @@ COM81.py:494:6: COM819 [*] Trailing comma prohibited COM81.py:496:21: COM819 [*] Trailing comma prohibited | 494 | (0, 1,) -495 | +495 | 496 | foo = ['a', 'b', 'c', ] | ^ COM819 -497 | +497 | 498 | bar = { a: b, } | = help: Remove trailing comma @@ -536,10 +535,10 @@ COM81.py:496:21: COM819 [*] Trailing comma prohibited COM81.py:498:13: COM819 [*] Trailing comma prohibited | 496 | foo = ['a', 'b', 'c', ] -497 | +497 | 498 | bar = { a: b, } | ^ COM819 -499 | +499 | 500 | def bah(ham, spam, ): | = help: Remove trailing comma @@ -557,7 +556,7 @@ COM81.py:498:13: COM819 [*] Trailing comma prohibited COM81.py:500:18: COM819 [*] Trailing comma prohibited | 498 | bar = { a: b, } -499 | +499 | 500 | def bah(ham, spam, ): | ^ COM819 501 | pass @@ -577,10 +576,10 @@ COM81.py:500:18: COM819 [*] Trailing comma prohibited COM81.py:505:6: COM819 [*] Trailing comma prohibited | 503 | (0, ) -504 | +504 | 505 | (0, 1, ) | ^ COM819 -506 | +506 | 507 | image[:, :, 0] | = help: Remove trailing comma @@ -598,10 +597,10 @@ COM81.py:505:6: COM819 [*] Trailing comma prohibited COM81.py:511:10: COM819 [*] Trailing comma prohibited | 509 | image[:,] -510 | +510 | 511 | image[:,:,] | ^ COM819 -512 | +512 | 513 | lambda x, : x | = help: Remove trailing comma @@ -619,10 +618,10 @@ COM81.py:511:10: COM819 [*] Trailing comma prohibited COM81.py:513:9: COM819 [*] Trailing comma prohibited | 511 | image[:,:,] -512 | +512 | 513 | lambda x, : x | ^ COM819 -514 | +514 | 515 | # ==> unpack.py <== | = help: Remove trailing comma @@ -642,7 +641,7 @@ COM81.py:519:13: COM812 [*] Trailing comma missing 517 | foo, 518 | bar, 519 | **kwargs - | COM812 + | ^ COM812 520 | ): 521 | pass | @@ -663,7 +662,7 @@ COM81.py:526:10: COM812 [*] Trailing comma missing 524 | foo, 525 | bar, 526 | *args - | COM812 + | ^ COM812 527 | ): 528 | pass | @@ -684,7 +683,7 @@ COM81.py:534:16: COM812 [*] Trailing comma missing 532 | bar, 533 | *args, 534 | extra_kwarg - | COM812 + | ^ COM812 535 | ): 536 | pass | @@ -705,7 +704,7 @@ COM81.py:541:13: COM812 [*] Trailing comma missing 539 | foo, 540 | bar, 541 | **kwargs - | COM812 + | ^ COM812 542 | ) | = help: Add trailing comma @@ -725,7 +724,7 @@ COM81.py:547:24: COM812 [*] Trailing comma missing 545 | foo, 546 | bar, 547 | **not_called_kwargs - | COM812 + | ^ COM812 548 | ) | = help: Add trailing comma @@ -745,7 +744,7 @@ COM81.py:554:15: COM812 [*] Trailing comma missing 552 | spam, 553 | *args, 554 | kwarg_only - | COM812 + | ^ COM812 555 | ): 556 | pass | @@ -765,7 +764,7 @@ COM81.py:561:13: COM812 [*] Trailing comma missing | 560 | foo( 561 | **kwargs - | COM812 + | ^ COM812 562 | ) | = help: Add trailing comma @@ -784,7 +783,7 @@ COM81.py:565:13: COM812 [*] Trailing comma missing | 564 | { 565 | **kwargs - | COM812 + | ^ COM812 566 | } | = help: Add trailing comma @@ -803,7 +802,7 @@ COM81.py:569:10: COM812 [*] Trailing comma missing | 568 | { 569 | *args - | COM812 + | ^ COM812 570 | } | = help: Add trailing comma @@ -822,7 +821,7 @@ COM81.py:573:10: COM812 [*] Trailing comma missing | 572 | [ 573 | *args - | COM812 + | ^ COM812 574 | ] | = help: Add trailing comma @@ -842,7 +841,7 @@ COM81.py:579:10: COM812 [*] Trailing comma missing 577 | ham, 578 | spam, 579 | *args - | COM812 + | ^ COM812 580 | ): 581 | pass | @@ -863,7 +862,7 @@ COM81.py:586:13: COM812 [*] Trailing comma missing 584 | ham, 585 | spam, 586 | **kwargs - | COM812 + | ^ COM812 587 | ): 588 | pass | @@ -884,7 +883,7 @@ COM81.py:594:15: COM812 [*] Trailing comma missing 592 | spam, 593 | *args, 594 | kwarg_only - | COM812 + | ^ COM812 595 | ): 596 | pass | @@ -905,7 +904,7 @@ COM81.py:623:20: COM812 [*] Trailing comma missing 621 | foo, 622 | bar, 623 | **{'ham': spam} - | COM812 + | ^ COM812 624 | ) | = help: Add trailing comma @@ -925,7 +924,7 @@ COM81.py:628:42: COM812 [*] Trailing comma missing 626 | # Make sure the COM812 and UP034 rules don't fix simultaneously and cause a syntax error. 627 | the_first_one = next( 628 | (i for i in range(10) if i // 2 == 0) # COM812 fix should include the final bracket - | COM812 + | ^ COM812 629 | ) | = help: Add trailing comma @@ -945,7 +944,7 @@ COM81.py:640:46: COM819 [*] Trailing comma prohibited 639 | # F-strings 640 | kwargs.pop("remove", f"this {trailing_comma}",) | ^ COM819 -641 | +641 | 642 | raise Exception( | = help: Remove trailing comma @@ -964,7 +963,7 @@ COM81.py:643:49: COM812 [*] Trailing comma missing | 642 | raise Exception( 643 | "first", extra=f"Add trailing comma here ->" - | COM812 + | ^ COM812 644 | ) | = help: Add trailing comma diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_0.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_0.py.snap index 160bdf5662289..93800dbe5bac3 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_0.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_0.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- W292_0.py:2:9: W292 [*] No newline at end of file | 1 | def fn() -> None: 2 | pass - | W292 + | ^ W292 | = help: Add trailing newline diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2512_invalid_characters.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2512_invalid_characters.py.snap index 645acf0bcb8f2..1720ccc3aa5b5 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2512_invalid_characters.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2512_invalid_characters.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- invalid_characters.py:24:12: PLE2512 [*] Invalid unescaped character SUB, use "\x1A" instead | 22 | cr_ok = f'\\r' -23 | +23 | 24 | sub = 'sub ' - | PLE2512 + | ^ PLE2512 25 | sub = f'sub ' | = help: Replace with escape sequence @@ -26,8 +25,8 @@ invalid_characters.py:25:13: PLE2512 [*] Invalid unescaped character SUB, use "\ | 24 | sub = 'sub ' 25 | sub = f'sub ' - | PLE2512 -26 | + | ^ PLE2512 +26 | 27 | sub_ok = '\x1a' | = help: Replace with escape sequence @@ -45,10 +44,10 @@ invalid_characters.py:25:13: PLE2512 [*] Invalid unescaped character SUB, use "\ invalid_characters.py:55:25: PLE2512 [*] Invalid unescaped character SUB, use "\x1A" instead | 53 | zwsp_after_multicharacter_grapheme_cluster = f"ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" -54 | +54 | 55 | nested_fstrings = f'␈{f'{f'␛'}'}' - | PLE2512 -56 | + | ^ PLE2512 +56 | 57 | # https://github.com/astral-sh/ruff/issues/7455#issuecomment-1741998106 | = help: Replace with escape sequence @@ -67,7 +66,7 @@ invalid_characters.py:58:12: PLE2512 [*] Invalid unescaped character SUB, use "\ | 57 | # https://github.com/astral-sh/ruff/issues/7455#issuecomment-1741998106 58 | x = f"""}}ab""" - | PLE2512 + | ^ PLE2512 59 | # https://github.com/astral-sh/ruff/issues/7455#issuecomment-1741998256 60 | x = f"""}}a␛b""" | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2514_invalid_characters.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2514_invalid_characters.py.snap index 4fc53d9aba4556ca823a13bc8841898f19bba071..49b80e52e968e879ab7851fce926d64001e83047 100644 GIT binary patch delta 39 vcmdnZwt{Vf`9$wd#<-1Fsu}s?6asu)jZ6(qxJ(QbYPco~G7C>GWI6=^0KE&; delta 52 zcmZ3%wwrB&xo~k_VnK06eo1_GW?qVwLP=^x$wafRjR&h4`4j?tT#ZZ(O}I=96lxSE IdokSu0Qa8}-v9sr diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2515_invalid_characters.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2515_invalid_characters.py.snap index eb6e952f038fd..6e29b04cba648 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2515_invalid_characters.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2515_invalid_characters.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- invalid_characters.py:44:13: PLE2515 [*] Invalid unescaped character zero-width-space, use "\u200B" instead | 42 | nul_ok = f'\0' -43 | +43 | 44 | zwsp = 'zero​width' - | PLE2515 + | ^ PLE2515 45 | zwsp = f'zero​width' | = help: Replace with escape sequence @@ -26,8 +25,8 @@ invalid_characters.py:45:14: PLE2515 [*] Invalid unescaped character zero-width- | 44 | zwsp = 'zero​width' 45 | zwsp = f'zero​width' - | PLE2515 -46 | + | ^ PLE2515 +46 | 47 | zwsp_ok = '\u200b' | = help: Replace with escape sequence @@ -45,9 +44,9 @@ invalid_characters.py:45:14: PLE2515 [*] Invalid unescaped character zero-width- invalid_characters.py:50:36: PLE2515 [*] Invalid unescaped character zero-width-space, use "\u200B" instead | 48 | zwsp_ok = f'\u200b' -49 | +49 | 50 | zwsp_after_multibyte_character = "ಫ​" - | PLE2515 + | ^ PLE2515 51 | zwsp_after_multibyte_character = f"ಫ​" 52 | zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" | @@ -67,7 +66,7 @@ invalid_characters.py:51:37: PLE2515 [*] Invalid unescaped character zero-width- | 50 | zwsp_after_multibyte_character = "ಫ​" 51 | zwsp_after_multibyte_character = f"ಫ​" - | PLE2515 + | ^ PLE2515 52 | zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" 53 | zwsp_after_multicharacter_grapheme_cluster = f"ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" | @@ -88,7 +87,7 @@ invalid_characters.py:52:60: PLE2515 [*] Invalid unescaped character zero-width- 50 | zwsp_after_multibyte_character = "ಫ​" 51 | zwsp_after_multibyte_character = f"ಫ​" 52 | zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" - | PLE2515 + | ^ PLE2515 53 | zwsp_after_multicharacter_grapheme_cluster = f"ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" | = help: Replace with escape sequence @@ -108,7 +107,7 @@ invalid_characters.py:52:61: PLE2515 [*] Invalid unescaped character zero-width- 50 | zwsp_after_multibyte_character = "ಫ​" 51 | zwsp_after_multibyte_character = f"ಫ​" 52 | zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" - | PLE2515 + | ^ PLE2515 53 | zwsp_after_multicharacter_grapheme_cluster = f"ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" | = help: Replace with escape sequence @@ -128,8 +127,8 @@ invalid_characters.py:53:61: PLE2515 [*] Invalid unescaped character zero-width- 51 | zwsp_after_multibyte_character = f"ಫ​" 52 | zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" 53 | zwsp_after_multicharacter_grapheme_cluster = f"ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" - | PLE2515 -54 | + | ^ PLE2515 +54 | 55 | nested_fstrings = f'␈{f'{f'␛'}'}' | = help: Replace with escape sequence @@ -149,8 +148,8 @@ invalid_characters.py:53:62: PLE2515 [*] Invalid unescaped character zero-width- 51 | zwsp_after_multibyte_character = f"ಫ​" 52 | zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" 53 | zwsp_after_multicharacter_grapheme_cluster = f"ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" - | PLE2515 -54 | + | ^ PLE2515 +54 | 55 | nested_fstrings = f'␈{f'{f'␛'}'}' | = help: Replace with escape sequence diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0202_no_method_decorator.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0202_no_method_decorator.py.snap index 436db3757a507..b59cccfa4c0ba 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0202_no_method_decorator.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0202_no_method_decorator.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- no_method_decorator.py:9:5: PLR0202 [*] Class method defined without decorator | 7 | self.color = color - 8 | + 8 | 9 | def pick_colors(cls, *args): # [no-classmethod-decorator] - | PLR0202 + | ^ PLR0202 10 | """classmethod to pick fruit colors""" 11 | cls.COLORS = args | @@ -31,7 +30,7 @@ no_method_decorator.py:22:5: PLR0202 [*] Class method defined without decorator | 21 | class Class: 22 | def class_method(cls): - | PLR0202 + | ^ PLR0202 23 | pass | = help: Add @classmethod decorator diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0203_no_method_decorator.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0203_no_method_decorator.py.snap index 9ef8f741f1770..49579ff4addf9 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0203_no_method_decorator.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0203_no_method_decorator.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- no_method_decorator.py:15:5: PLR0203 [*] Static method defined without decorator | 13 | pick_colors = classmethod(pick_colors) -14 | +14 | 15 | def pick_one_color(): # [no-staticmethod-decorator] - | PLR0203 + | ^ PLR0203 16 | """staticmethod to pick one fruit color""" 17 | return choice(Fruit.COLORS) | @@ -30,9 +29,9 @@ no_method_decorator.py:15:5: PLR0203 [*] Static method defined without decorator no_method_decorator.py:27:5: PLR0203 [*] Static method defined without decorator | 25 | class_method = classmethod(class_method);another_statement -26 | +26 | 27 | def static_method(): - | PLR0203 + | ^ PLR0203 28 | pass | = help: Add @staticmethod decorator diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__no_member.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__no_member.py.snap index 9de860a7e9acf..440c42423fefe 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__no_member.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__no_member.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/attribute/no_member.py -snapshot_kind: text --- ## AST @@ -77,7 +76,7 @@ Module( 2 | first. | ^ Syntax Error: Expected an identifier 3 | second -4 | +4 | 5 | # No member access after the dot. | @@ -85,5 +84,5 @@ Module( | 5 | # No member access after the dot. 6 | last. - | Syntax Error: Expected an identifier + | ^ Syntax Error: Expected an identifier | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_0.py.snap index 1772420cc3894..45b456fe189ec 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_0.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/dict/missing_closing_brace_0.py -snapshot_kind: text --- ## AST @@ -76,7 +75,7 @@ Module( | 1 | {x: -2 | +2 | 3 | def foo(): | ^^^ Syntax Error: Expected an identifier, but found a keyword 'def' that cannot be used here 4 | pass @@ -85,7 +84,7 @@ Module( | 1 | {x: -2 | +2 | 3 | def foo(): | ^^^ Syntax Error: Expected ',', found name 4 | pass @@ -102,5 +101,5 @@ Module( | 3 | def foo(): 4 | pass - | Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: unexpected EOF while parsing | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_1.py.snap index 32c099e2d8307..67b4fca986ec0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_1.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/dict/missing_closing_brace_1.py -snapshot_kind: text --- ## AST @@ -63,7 +62,7 @@ Module( | 1 | {x: -2 | +2 | 3 | 1 + 2 - | Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: unexpected EOF while parsing | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_0.py.snap index 5e81f96ceb634..efe0f9aaa32cb 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_0.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/list/missing_closing_bracket_0.py -snapshot_kind: text --- ## AST @@ -38,7 +37,7 @@ Module( | 1 | # Missing closing bracket 0: No elements -2 | +2 | 3 | [ - | Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: unexpected EOF while parsing | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_1.py.snap index da3aa39c6766e..20f04c756cc78 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_1.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/list/missing_closing_bracket_1.py -snapshot_kind: text --- ## AST @@ -51,7 +50,7 @@ Module( | 4 | [ -5 | +5 | 6 | x + y - | Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: unexpected EOF while parsing | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_2.py.snap index f4e434adf963a..c253897cdee8f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_2.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/list/missing_closing_bracket_2.py -snapshot_kind: text --- ## AST @@ -59,7 +58,7 @@ Module( | 4 | [1, -5 | +5 | 6 | x + y - | Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: unexpected EOF while parsing | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_0.py.snap index 12ee7676da1b6..33371ac311523 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_0.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/named/missing_expression_0.py -snapshot_kind: text --- ## AST @@ -30,7 +29,7 @@ Module( | 1 | # There are no parentheses, so this isn't parsed as named expression. -2 | +2 | 3 | x := | ^^ Syntax Error: Expected a statement | @@ -38,7 +37,7 @@ Module( | 1 | # There are no parentheses, so this isn't parsed as named expression. -2 | +2 | 3 | x := - | Syntax Error: Expected a statement + | ^ Syntax Error: Expected a statement | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_1.py.snap index 16d52ec7317e7..7fbfdf4dc9204 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_1.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/named/missing_expression_1.py -snapshot_kind: text --- ## AST @@ -42,7 +41,7 @@ Module( | 1 | # EOF after the `:=` token -2 | +2 | 3 | (x := - | Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: unexpected EOF while parsing | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_2.py.snap index 56f90d1fe0b4b..77c7726c6944e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_2.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/named/missing_expression_2.py -snapshot_kind: text --- ## AST @@ -73,7 +72,7 @@ Module( | 3 | (x := -4 | +4 | 5 | def foo(): | ^^^ Syntax Error: Expected an identifier, but found a keyword 'def' that cannot be used here 6 | pass @@ -82,7 +81,7 @@ Module( | 3 | (x := -4 | +4 | 5 | def foo(): | ^^^ Syntax Error: Expected ')', found name 6 | pass @@ -99,5 +98,5 @@ Module( | 5 | def foo(): 6 | pass - | Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: unexpected EOF while parsing | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_3.py.snap index 1ed8f87cb8c4b..1ec0d5d924e36 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_3.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/named/missing_expression_3.py -snapshot_kind: text --- ## AST @@ -55,7 +54,7 @@ Module( | 4 | (x := -5 | +5 | 6 | x + y - | Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: unexpected EOF while parsing | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__generator.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__generator.py.snap index b68f04591ef06..f547981164cd1 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__generator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__generator.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/parenthesized/generator.py -snapshot_kind: text --- ## AST @@ -141,5 +140,5 @@ Module( | 1 | (*x for x in y) 2 | (x := 1, for x in y) - | Syntax Error: Expected a statement + | ^ Syntax Error: Expected a statement | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_0.py.snap index 30683ad380fe8..7b610ed0d11b4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_0.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/parenthesized/missing_closing_paren_0.py -snapshot_kind: text --- ## AST @@ -30,7 +29,7 @@ Module( | 1 | # Missing closing parentheses 0: No elements -2 | +2 | 3 | ( - | Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: unexpected EOF while parsing | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_1.py.snap index 64ffde419b078..02ff2cf395a0f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_1.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/parenthesized/missing_closing_paren_1.py -snapshot_kind: text --- ## AST @@ -43,7 +42,7 @@ Module( | 4 | ( -5 | +5 | 6 | x + y - | Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: unexpected EOF while parsing | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_2.py.snap index e268257d971fe..b793308c04bef 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_2.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/parenthesized/missing_closing_paren_2.py -snapshot_kind: text --- ## AST @@ -60,7 +59,7 @@ Module( | 4 | (1, -5 | +5 | 6 | x + y - | Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: unexpected EOF while parsing | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_0.py.snap index cdab57cf20744..6b082389bac73 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_0.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/set/missing_closing_curly_brace_0.py -snapshot_kind: text --- ## AST @@ -37,7 +36,7 @@ Module( | 1 | # Missing closing curly brace 0: No elements -2 | +2 | 3 | { - | Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: unexpected EOF while parsing | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_1.py.snap index b447c3cbd2a89..3df9492f91909 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_1.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/set/missing_closing_curly_brace_1.py -snapshot_kind: text --- ## AST @@ -50,7 +49,7 @@ Module( | 4 | { -5 | +5 | 6 | x + y - | Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: unexpected EOF while parsing | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_2.py.snap index b85e57ae47ed6..101fbf0b1ab90 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_2.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/set/missing_closing_curly_brace_2.py -snapshot_kind: text --- ## AST @@ -58,7 +57,7 @@ Module( | 4 | {1, -5 | +5 | 6 | x + y - | Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: unexpected EOF while parsing | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_0.py.snap index 2480021a91c01..6491277ca7bcb 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_0.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/subscript/unclosed_slice_0.py -snapshot_kind: text --- ## AST @@ -65,7 +64,7 @@ Module( | 1 | x[: -2 | +2 | 3 | x + y - | Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: unexpected EOF while parsing | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_1.py.snap index bd258eb055f18..10505cb6cb40c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_1.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/expressions/subscript/unclosed_slice_1.py -snapshot_kind: text --- ## AST @@ -83,7 +82,7 @@ Module( | 1 | x[:: -2 | +2 | 3 | def foo(): | ^^^ Syntax Error: Expected an identifier, but found a keyword 'def' that cannot be used here 4 | pass @@ -92,7 +91,7 @@ Module( | 1 | x[:: -2 | +2 | 3 | def foo(): | ^^^ Syntax Error: Expected ']', found name 4 | pass @@ -109,5 +108,5 @@ Module( | 3 | def foo(): 4 | pass - | Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: unexpected EOF while parsing | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace.py.snap index 939fc90c874a8..7714d9e16286f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/inline/err/f_string_unclosed_lbrace.py -snapshot_kind: text --- ## AST @@ -224,7 +223,7 @@ Module( | 1 | f"{" - | Syntax Error: f-string: unterminated string + | ^ Syntax Error: f-string: unterminated string 2 | f"{foo!r" 3 | f"{foo=" | @@ -232,7 +231,7 @@ Module( | 1 | f"{" - | Syntax Error: f-string: unterminated string + | ^ Syntax Error: f-string: unterminated string 2 | f"{foo!r" 3 | f"{foo=" | @@ -250,7 +249,7 @@ Module( | 1 | f"{" 2 | f"{foo!r" - | Syntax Error: f-string: unterminated string + | ^ Syntax Error: f-string: unterminated string 3 | f"{foo=" 4 | f"{" | @@ -259,7 +258,7 @@ Module( | 1 | f"{" 2 | f"{foo!r" - | Syntax Error: f-string: unterminated string + | ^ Syntax Error: f-string: unterminated string 3 | f"{foo=" 4 | f"{" | @@ -278,7 +277,7 @@ Module( | 1 | f"{" 2 | f"{foo!r" - | Syntax Error: Expected FStringEnd, found Unknown + | ^ Syntax Error: Expected FStringEnd, found Unknown 3 | f"{foo=" 4 | f"{" | @@ -298,7 +297,7 @@ Module( 1 | f"{" 2 | f"{foo!r" 3 | f"{foo=" - | Syntax Error: f-string: unterminated string + | ^ Syntax Error: f-string: unterminated string 4 | f"{" 5 | f"""{""" | @@ -308,7 +307,7 @@ Module( 1 | f"{" 2 | f"{foo!r" 3 | f"{foo=" - | Syntax Error: f-string: unterminated string + | ^ Syntax Error: f-string: unterminated string 4 | f"{" 5 | f"""{""" | @@ -342,10 +341,12 @@ Module( | 4 | f"{" 5 | f"""{""" + | ^ Syntax Error: unexpected EOF while parsing | | 4 | f"{" 5 | f"""{""" + | ^ Syntax Error: f-string: unterminated string | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string.py.snap index 590262df43480..2ba54bef2f7d5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/inline/err/implicitly_concatenated_unterminated_string.py -snapshot_kind: text --- ## AST @@ -174,6 +173,6 @@ Module( 1 | 'hello' 'world 2 | 1 + 1 3 | 'hello' f'world {x} - | Syntax Error: f-string: unterminated string + | ^ Syntax Error: f-string: unterminated string 4 | 2 + 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string_multiline.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string_multiline.py.snap index 65d715c89f858..cdfccb44422a7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string_multiline.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string_multiline.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/inline/err/implicitly_concatenated_unterminated_string_multiline.py -snapshot_kind: text --- ## AST @@ -189,7 +188,7 @@ Module( 1 | ( 2 | 'hello' 3 | f'world {x} - | Syntax Error: f-string: unterminated string + | ^ Syntax Error: f-string: unterminated string 4 | ) 5 | 1 + 1 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap index dcb1577f3ef2f..48dc7f7866b8d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/re_lex_logical_token.py -snapshot_kind: text --- ## AST @@ -708,8 +707,8 @@ Module( 13 | # There are multiple non-logical newlines (blank lines) in the `if` body 14 | if call(foo | ^ Syntax Error: Expected ')', found newline -15 | -16 | +15 | +16 | 17 | def bar(): | @@ -775,7 +774,7 @@ Module( | 49 | # F-strings uses normal list parsing, so test those as well 50 | if call(f"hello {x - | Syntax Error: f-string: unterminated string + | ^ Syntax Error: f-string: unterminated string 51 | def bar(): 52 | pass | @@ -793,7 +792,7 @@ Module( | 49 | # F-strings uses normal list parsing, so test those as well 50 | if call(f"hello {x - | Syntax Error: Expected FStringEnd, found Unknown + | ^ Syntax Error: Expected FStringEnd, found Unknown 51 | def bar(): 52 | pass | @@ -835,5 +834,5 @@ Module( 55 | if call(f"hello 56 | def bar(): 57 | pass - | Syntax Error: Expected a statement + | ^ Syntax Error: Expected a statement | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_mac_eol.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_mac_eol.py.snap index 99399eceaa87d..e9879e5ba3305 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_mac_eol.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_mac_eol.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/re_lex_logical_token_mac_eol.py -snapshot_kind: text --- ## AST @@ -101,5 +100,5 @@ Module( | 1 | if call(foo, [a, b def bar(): pass - | Syntax Error: Expected ']', found NonLogicalNewline + | ^ Syntax Error: Expected ']', found NonLogicalNewline | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap index 93c7e8dfcc254..472a8579cc596 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/re_lexing/triple_quoted_fstring_1.py -snapshot_kind: text --- ## AST @@ -65,7 +64,7 @@ Module( | 3 | # https://github.com/astral-sh/ruff/issues/11929 -4 | +4 | 5 | f"""hello {x # comment | ___________________________^ 6 | | y = 1 @@ -82,7 +81,7 @@ Module( | 3 | # https://github.com/astral-sh/ruff/issues/11929 -4 | +4 | 5 | f"""hello {x # comment | ___________________________^ 6 | | y = 1 @@ -93,5 +92,5 @@ Module( | 5 | f"""hello {x # comment 6 | y = 1 - | Syntax Error: Expected a statement + | ^ Syntax Error: Expected a statement | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar.py.snap index 3e9448c829a08..e389ad74809d9 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/statements/with/unclosed_ambiguous_lpar.py -snapshot_kind: text --- ## AST @@ -65,14 +64,14 @@ Module( | 1 | with (: | ^ Syntax Error: Expected an expression -2 | +2 | 3 | x + y | | 1 | with (: -2 | +2 | 3 | x + y - | Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: unexpected EOF while parsing | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar_eof.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar_eof.py.snap index 9c6ad99b9d6e2..057cb44426006 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar_eof.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar_eof.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/statements/with/unclosed_ambiguous_lpar_eof.py -snapshot_kind: text --- ## AST @@ -38,5 +37,5 @@ Module( | 1 | with ( - | Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: unexpected EOF while parsing | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap index dafe6ce39c092..c2c29483fd578 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/inline/err/unterminated_fstring_newline_recovery.py -snapshot_kind: text --- ## AST @@ -316,7 +315,7 @@ Module( 1 | f"hello 2 | 1 + 1 3 | f"hello {x - | Syntax Error: f-string: unterminated string + | ^ Syntax Error: f-string: unterminated string 4 | 2 + 2 5 | f"hello {x: | @@ -336,7 +335,7 @@ Module( 1 | f"hello 2 | 1 + 1 3 | f"hello {x - | Syntax Error: Expected FStringEnd, found Unknown + | ^ Syntax Error: Expected FStringEnd, found Unknown 4 | 2 + 2 5 | f"hello {x: | @@ -346,7 +345,7 @@ Module( 3 | f"hello {x 4 | 2 + 2 5 | f"hello {x: - | Syntax Error: f-string: unterminated string + | ^ Syntax Error: f-string: unterminated string 6 | 3 + 3 7 | f"hello {x} | @@ -356,6 +355,6 @@ Module( 5 | f"hello {x: 6 | 3 + 3 7 | f"hello {x} - | Syntax Error: f-string: unterminated string + | ^ Syntax Error: f-string: unterminated string 8 | 4 + 4 | From bfcd48ef77729b9b5325b0804a1f3c132849d7c6 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Tue, 7 Jan 2025 14:46:50 -0500 Subject: [PATCH 09/18] test: update snapshots with improper end-of-line placement This looks like a bug fix that occurs when the annotation is a zero-width span immediately following a line terminator. Previously, the caret seems to be rendered on the next line, but it should be rendered at the end of the line the span corresponds to. I admit that this one is kinda weird. I would somewhat expect that our spans here are actually incorrect, and that to obtain this sort of rendering, we should identify a span just immediately _before_ the line terminator and not after it. But I don't want to dive into that rabbit hole for now (and given how `annotate-snippets` now renders these spans, perhaps there is more to it than I see), and this does seem like a clear improvement given the spans we feed to `annotate-snippets`. --- ...rules__isort__tests__line_ending_crlf.py.snap | 7 +++---- ...__rules__isort__tests__line_ending_lf.py.snap | 7 +++---- ...er__rules__isort__tests__no_wrap_star.py.snap | 4 ++-- ...ff_linter__rules__isort__tests__split.py.snap | 16 ++++++++-------- ...nvalid_syntax@if_stmt_misspelled_elif.py.snap | 4 ++-- ...syntax@match_stmt_expected_case_block.py.snap | 4 ++-- ...ntax@re_lex_logical_token_windows_eol.py.snap | 10 ++++------ ...lexing__line_continuation_windows_eol.py.snap | 12 +++++------- 8 files changed, 29 insertions(+), 35 deletions(-) diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_crlf.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_crlf.py.snap index fd6eeec94b4fe..7a82945f6454a 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_crlf.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_crlf.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- line_ending_crlf.py:1:1: I001 [*] Import block is un-sorted or un-formatted | -1 | / from long_module_name import member_one, member_two, member_three, member_four, member_five -2 | | - | |_^ I001 +1 | from long_module_name import member_one, member_two, member_three, member_four, member_five + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I001 +2 | | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_lf.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_lf.py.snap index cdf02f650d21d..88cb9c8fabd29 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_lf.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_lf.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- line_ending_lf.py:1:1: I001 [*] Import block is un-sorted or un-formatted | -1 | / from long_module_name import member_one, member_two, member_three, member_four, member_five -2 | | - | |_^ I001 +1 | from long_module_name import member_one, member_two, member_three, member_four, member_five + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I001 +2 | | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_wrap_star.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_wrap_star.py.snap index e4116bc0770c7..cdaf1e3466551 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_wrap_star.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_wrap_star.py.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- no_wrap_star.py:1:1: I001 [*] Import block is un-sorted or un-formatted | -1 | / from .subscription import * # type: ignore # some very long comment explaining why this needs a type ignore +1 | from .subscription import * # type: ignore # some very long comment explaining why this needs a type ignore + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split.py.snap index aa180869321d3..40de22a2329d8 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- split.py:15:1: I001 [*] Import block is un-sorted or un-formatted | 14 | if True: 15 | / import C 16 | | import A -17 | | - | |_^ I001 + | |_____________^ I001 +17 | 18 | # isort: split | = help: Organize imports @@ -27,12 +26,12 @@ split.py:15:1: I001 [*] Import block is un-sorted or un-formatted split.py:20:1: I001 [*] Import block is un-sorted or un-formatted | 18 | # isort: split -19 | +19 | 20 | / import D 21 | | import B -22 | | - | |_^ I001 -23 | + | |_____________^ I001 +22 | +23 | 24 | import e | = help: Organize imports @@ -51,9 +50,10 @@ split.py:20:1: I001 [*] Import block is un-sorted or un-formatted split.py:30:1: I001 [*] Import block is un-sorted or un-formatted | 28 | # isort: split -29 | +29 | 30 | / import d 31 | | import c + | |_________^ I001 | = help: Organize imports diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_misspelled_elif.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_misspelled_elif.py.snap index 8be2a8ac490b3..b8d421961c8f6 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_misspelled_elif.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_misspelled_elif.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/inline/err/if_stmt_misspelled_elif.py -snapshot_kind: text --- ## AST @@ -90,8 +89,8 @@ Module( | 3 | elf: 4 | pass + | ^ Syntax Error: Expected a statement 5 | else: - | Syntax Error: Expected a statement 6 | pass | @@ -125,4 +124,5 @@ Module( | 5 | else: 6 | pass + | ^ Syntax Error: Expected a statement | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expected_case_block.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expected_case_block.py.snap index ec0d060459beb..2844e904f7156 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expected_case_block.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expected_case_block.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/inline/err/match_stmt_expected_case_block.py -snapshot_kind: text --- ## AST @@ -113,8 +112,8 @@ Module( | 1 | match x: 2 | x = 1 + | ^ Syntax Error: Expected a statement 3 | match x: - | Syntax Error: Expected a statement 4 | match y: 5 | case _: ... | @@ -132,4 +131,5 @@ Module( | 4 | match y: 5 | case _: ... + | ^ Syntax Error: Expected a statement | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_windows_eol.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_windows_eol.py.snap index 912c68cf07494..31bb3a87f2044 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_windows_eol.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_windows_eol.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/re_lex_logical_token_windows_eol.py -snapshot_kind: text --- ## AST @@ -100,9 +99,8 @@ Module( ## Errors | -1 | if call(foo, [a, b - | ___________________^ -2 | | def bar(): - | |_^ Syntax Error: Expected ']', found NonLogicalNewline -3 | pass +1 | if call(foo, [a, b + | ^ Syntax Error: Expected ']', found NonLogicalNewline +2 | def bar(): +3 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_windows_eol.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_windows_eol.py.snap index b7679b43b9949..935f436e821bd 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_windows_eol.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_windows_eol.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/re_lexing/line_continuation_windows_eol.py -snapshot_kind: text --- ## AST @@ -82,10 +81,9 @@ Module( ## Errors | -1 | call(a, b, # comment \ - | _______________________^ -2 | | - | |_^ Syntax Error: Expected ')', found newline -3 | def bar(): -4 | pass +1 | call(a, b, # comment \ + | ^ Syntax Error: Expected ')', found newline +2 | +3 | def bar(): +4 | pass | From 9432587aa60521ac1ff52472c9b1ff8ba4bb12c8 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Tue, 7 Jan 2025 15:09:42 -0500 Subject: [PATCH 10/18] test: another line terminator bug fix I believe this case is different from the last in that it happens when the end of a *multi-line* annotation occurs after a line terminator. Previously, the diagnostic would render on the next line, which is definitely a bit weird. This new update renders it at the end of the line the annotation ends on. In some cases, the annotation was previously rendered to point at source lines below where the error occurred, which is probably pretty confusing. --- ...__isort__tests__insert_empty_lines.py.snap | 21 +++---- ..._isort__tests__insert_empty_lines.pyi.snap | 15 +++-- ...s__lines_after_imports_class_after.py.snap | 13 ++-- ...ts_lines_after_imports_class_after.py.snap | 13 ++-- ...r__rules__isort__tests__match_case.py.snap | 6 +- ...isort__tests__preserve_indentation.py.snap | 6 +- ...er__rules__isort__tests__two_space.py.snap | 7 +-- ...ules__pycodestyle__tests__E112_E11.py.snap | 5 +- ...ules__pycodestyle__tests__E115_E11.py.snap | 13 ++-- ...__rules__pydocstyle__tests__D207_D.py.snap | 17 +++-- ...__rules__pydocstyle__tests__D208_D.py.snap | 63 +++++++++---------- ...ules__pydocstyle__tests__D208_D208.py.snap | 25 ++++---- ...sts__PLE2502_bidirectional_unicode.py.snap | 47 +++++++------- ...linter__linter__tests__import_sorting.snap | 18 +++--- ...x@re_lexing__fstring_format_spec_1.py.snap | 27 ++++---- ...syntax@statements__if_extra_indent.py.snap | 7 +-- ..._syntax@try_stmt_misspelled_except.py.snap | 7 +-- 17 files changed, 148 insertions(+), 162 deletions(-) diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.py.snap index 9690dc9537bf8..fa92501dd7055 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- insert_empty_lines.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / import a 2 | | import b -3 | | x = 1 - | |_^ I001 + | |_________^ I001 +3 | x = 1 4 | import os 5 | import sys | @@ -27,8 +26,8 @@ insert_empty_lines.py:4:1: I001 [*] Import block is un-sorted or un-formatted 3 | x = 1 4 | / import os 5 | | import sys -6 | | def f(): - | |_^ I001 + | |___________^ I001 +6 | def f(): 7 | pass 8 | if True: | @@ -50,9 +49,9 @@ insert_empty_lines.py:14:1: I001 [*] Import block is un-sorted or un-formatted 13 | y = 1 14 | / import os 15 | | import sys -16 | | """Docstring""" - | |_^ I001 -17 | + | |___________^ I001 +16 | """Docstring""" +17 | 18 | if True: | = help: Organize imports @@ -69,9 +68,9 @@ insert_empty_lines.py:14:1: I001 [*] Import block is un-sorted or un-formatted insert_empty_lines.py:52:1: I001 [*] Import block is un-sorted or un-formatted | 52 | / import os -53 | | -54 | | # Comment goes here. - | |_^ I001 +53 | | + | |__^ I001 +54 | # Comment goes here. 55 | def f(): 56 | pass | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.pyi.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.pyi.snap index a9a450c2b39e2..7559c9bfb3455 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.pyi.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.pyi.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- insert_empty_lines.pyi:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / import a 2 | | import b -3 | | x = 1 - | |_^ I001 + | |_________^ I001 +3 | x = 1 4 | import os 5 | import sys | @@ -27,8 +26,8 @@ insert_empty_lines.pyi:4:1: I001 [*] Import block is un-sorted or un-formatted 3 | x = 1 4 | / import os 5 | | import sys -6 | | def f(): - | |_^ I001 + | |___________^ I001 +6 | def f(): 7 | pass 8 | if True: | @@ -49,9 +48,9 @@ insert_empty_lines.pyi:14:1: I001 [*] Import block is un-sorted or un-formatted 13 | y = 1 14 | / import os 15 | | import sys -16 | | """Docstring""" - | |_^ I001 -17 | + | |___________^ I001 +16 | """Docstring""" +17 | 18 | if True: | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_class_after.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_class_after.py.snap index 6b12c68c08f4a..d0524b5e0c7d8 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_class_after.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_class_after.py.snap @@ -1,20 +1,19 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- lines_after_imports_class_after.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from __future__ import annotations - 2 | | + 2 | | 3 | | from typing import Any - 4 | | + 4 | | 5 | | from requests import Session - 6 | | + 6 | | 7 | | from my_first_party import my_first_party_object - 8 | | + 8 | | 9 | | from . import my_local_folder_object -10 | | class Thing(object): - | |_^ I001 + | |_____________________________________^ I001 +10 | class Thing(object): 11 | name: str 12 | def __init__(self, name: str): | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_class_after.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_class_after.py.snap index 7a01afa39704f..19064fcfc5ee2 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_class_after.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_class_after.py.snap @@ -1,20 +1,19 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- lines_after_imports_class_after.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from __future__ import annotations - 2 | | + 2 | | 3 | | from typing import Any - 4 | | + 4 | | 5 | | from requests import Session - 6 | | + 6 | | 7 | | from my_first_party import my_first_party_object - 8 | | + 8 | | 9 | | from . import my_local_folder_object -10 | | class Thing(object): - | |_^ I001 + | |_____________________________________^ I001 +10 | class Thing(object): 11 | name: str 12 | def __init__(self, name: str): | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__match_case.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__match_case.py.snap index 67da838e16db8..253619595f106 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__match_case.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__match_case.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- match_case.py:3:1: I001 [*] Import block is un-sorted or un-formatted | @@ -8,8 +7,8 @@ match_case.py:3:1: I001 [*] Import block is un-sorted or un-formatted 2 | case 1: 3 | / import sys 4 | | import os -5 | | case 2: - | |_^ I001 + | |__________________^ I001 +5 | case 2: 6 | import collections 7 | import abc | @@ -31,6 +30,7 @@ match_case.py:6:1: I001 [*] Import block is un-sorted or un-formatted 5 | case 2: 6 | / import collections 7 | | import abc + | |___________________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_indentation.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_indentation.py.snap index 50b7f816b7aae..da983d3af7b83 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_indentation.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_indentation.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- preserve_indentation.py:2:1: I001 [*] Import block is un-sorted or un-formatted | 1 | if True: 2 | / import sys 3 | | import os -4 | | else: - | |_^ I001 + | |______________^ I001 +4 | else: 5 | import sys 6 | import os | @@ -29,6 +28,7 @@ preserve_indentation.py:5:1: I001 [*] Import block is un-sorted or un-formatted 4 | else: 5 | / import sys 6 | | import os + | |______________^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__two_space.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__two_space.py.snap index ed6afa3a609cd..43598e088102d 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__two_space.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__two_space.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- two_space.py:2:1: I001 [*] Import block is un-sorted or un-formatted | @@ -12,9 +11,9 @@ two_space.py:2:1: I001 [*] Import block is un-sorted or un-formatted 6 | | nan, 7 | | pi, 8 | | ) - 9 | | -10 | | del sin, cos, tan, pi, nan - | |_^ I001 + 9 | | + | |__^ I001 +10 | del sin, cos, tan, pi, nan | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E112_E11.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E112_E11.py.snap index c25b450d50cb8..e03f95c1975e9 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E112_E11.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E112_E11.py.snap @@ -1,13 +1,12 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E11.py:9:1: E112 Expected an indented block | 7 | #: E112 8 | if False: + | ^ E112 9 | print() - | E112 10 | #: E113 11 | print() | @@ -46,8 +45,8 @@ E11.py:45:1: E112 Expected an indented block | 43 | #: E112 44 | if False: # + | ^ E112 45 | print() - | E112 46 | #: 47 | if False: | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E115_E11.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E115_E11.py.snap index 565fc858e328b..e9ceedc539965 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E115_E11.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E115_E11.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E11.py:9:1: SyntaxError: Expected an indented block after `if` statement | @@ -36,8 +35,8 @@ E11.py:30:1: E115 Expected an indented block (comment) | 28 | def start(self): 29 | if True: + | ^ E115 30 | # try: - | E115 31 | # self.master.start() 32 | # except MasterExit: | @@ -46,8 +45,8 @@ E11.py:31:1: E115 Expected an indented block (comment) | 29 | if True: 30 | # try: + | ^ E115 31 | # self.master.start() - | E115 32 | # except MasterExit: 33 | # self.shutdown() | @@ -56,8 +55,8 @@ E11.py:32:1: E115 Expected an indented block (comment) | 30 | # try: 31 | # self.master.start() + | ^ E115 32 | # except MasterExit: - | E115 33 | # self.shutdown() 34 | # finally: | @@ -66,8 +65,8 @@ E11.py:33:1: E115 Expected an indented block (comment) | 31 | # self.master.start() 32 | # except MasterExit: + | ^ E115 33 | # self.shutdown() - | E115 34 | # finally: 35 | # sys.exit() | @@ -76,8 +75,8 @@ E11.py:34:1: E115 Expected an indented block (comment) | 32 | # except MasterExit: 33 | # self.shutdown() + | ^ E115 34 | # finally: - | E115 35 | # sys.exit() 36 | self.master.start() | @@ -86,8 +85,8 @@ E11.py:35:1: E115 Expected an indented block (comment) | 33 | # self.shutdown() 34 | # finally: + | ^ E115 35 | # sys.exit() - | E115 36 | self.master.start() 37 | #: E117 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D207_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D207_D.py.snap index c330b6cde7be8..ce92a1dd925ae 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D207_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D207_D.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D.py:232:1: D207 [*] Docstring is under-indented | 230 | """Summary. -231 | +231 | + | ^ D207 232 | Description. - | D207 -233 | +233 | 234 | """ | = help: Increase indentation @@ -26,9 +25,9 @@ D.py:232:1: D207 [*] Docstring is under-indented D.py:244:1: D207 [*] Docstring is under-indented | 242 | Description. -243 | +243 | + | ^ D207 244 | """ - | D207 | = help: Increase indentation @@ -45,9 +44,9 @@ D.py:244:1: D207 [*] Docstring is under-indented D.py:440:1: D207 [*] Docstring is under-indented | 438 | def docstring_start_in_same_line(): """First Line. -439 | +439 | + | ^ D207 440 | Second Line - | D207 441 | """ | = help: Increase indentation @@ -65,8 +64,8 @@ D.py:440:1: D207 [*] Docstring is under-indented D.py:441:1: D207 [*] Docstring is under-indented | 440 | Second Line + | ^ D207 441 | """ - | D207 | = help: Increase indentation diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D.py.snap index fd8b5e3228750..a49cb9db25735 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D.py:252:1: D208 [*] Docstring is over-indented | 250 | """Summary. -251 | +251 | + | ^ D208 252 | Description. - | D208 -253 | +253 | 254 | """ | = help: Remove over-indentation @@ -26,9 +25,9 @@ D.py:252:1: D208 [*] Docstring is over-indented D.py:264:1: D208 [*] Docstring is over-indented | 262 | Description. -263 | +263 | + | ^ D208 264 | """ - | D208 | = help: Remove over-indentation @@ -45,10 +44,10 @@ D.py:264:1: D208 [*] Docstring is over-indented D.py:272:1: D208 [*] Docstring is over-indented | 270 | """Summary. -271 | +271 | + | ^ D208 272 | Description. - | D208 -273 | +273 | 274 | """ | = help: Remove over-indentation @@ -66,9 +65,9 @@ D.py:272:1: D208 [*] Docstring is over-indented D.py:673:1: D208 [*] Docstring is over-indented | 671 | """Summary. -672 | +672 | + | ^ D208 673 | This is overindented - | D208 674 | And so is this, but it we should preserve the extra space on this line relative 675 | to the one before | @@ -87,8 +86,8 @@ D.py:673:1: D208 [*] Docstring is over-indented D.py:674:1: D208 [*] Docstring is over-indented | 673 | This is overindented + | ^ D208 674 | And so is this, but it we should preserve the extra space on this line relative - | D208 675 | to the one before 676 | """ | @@ -108,8 +107,8 @@ D.py:675:1: D208 [*] Docstring is over-indented | 673 | This is overindented 674 | And so is this, but it we should preserve the extra space on this line relative + | ^ D208 675 | to the one before - | D208 676 | """ | = help: Remove over-indentation @@ -127,9 +126,9 @@ D.py:675:1: D208 [*] Docstring is over-indented D.py:682:1: D208 [*] Docstring is over-indented | 680 | """Summary. -681 | +681 | + | ^ D208 682 | This is overindented - | D208 683 | And so is this, but it we should preserve the extra space on this line relative 684 | to the one before | @@ -148,8 +147,8 @@ D.py:682:1: D208 [*] Docstring is over-indented D.py:683:1: D208 [*] Docstring is over-indented | 682 | This is overindented + | ^ D208 683 | And so is this, but it we should preserve the extra space on this line relative - | D208 684 | to the one before 685 | This is also overindented | @@ -169,8 +168,8 @@ D.py:684:1: D208 [*] Docstring is over-indented | 682 | This is overindented 683 | And so is this, but it we should preserve the extra space on this line relative + | ^ D208 684 | to the one before - | D208 685 | This is also overindented 686 | And so is this, but it we should preserve the extra space on this line relative | @@ -190,8 +189,8 @@ D.py:685:1: D208 [*] Docstring is over-indented | 683 | And so is this, but it we should preserve the extra space on this line relative 684 | to the one before + | ^ D208 685 | This is also overindented - | D208 686 | And so is this, but it we should preserve the extra space on this line relative 687 | to the one before | @@ -211,8 +210,8 @@ D.py:686:1: D208 [*] Docstring is over-indented | 684 | to the one before 685 | This is also overindented + | ^ D208 686 | And so is this, but it we should preserve the extra space on this line relative - | D208 687 | to the one before 688 | """ | @@ -232,8 +231,8 @@ D.py:687:1: D208 [*] Docstring is over-indented | 685 | This is also overindented 686 | And so is this, but it we should preserve the extra space on this line relative + | ^ D208 687 | to the one before - | D208 688 | """ | = help: Remove over-indentation @@ -251,9 +250,9 @@ D.py:687:1: D208 [*] Docstring is over-indented D.py:695:1: D208 [*] Docstring is over-indented | 693 | """Summary. -694 | +694 | + | ^ D208 695 | This is overindented - | D208 696 | And so is this, but it we should preserve the extra space on this line relative 697 | to the one before | @@ -272,8 +271,8 @@ D.py:695:1: D208 [*] Docstring is over-indented D.py:696:1: D208 [*] Docstring is over-indented | 695 | This is overindented + | ^ D208 696 | And so is this, but it we should preserve the extra space on this line relative - | D208 697 | to the one before 698 | And the relative indent here should be preserved too | @@ -293,8 +292,8 @@ D.py:697:1: D208 [*] Docstring is over-indented | 695 | This is overindented 696 | And so is this, but it we should preserve the extra space on this line relative + | ^ D208 697 | to the one before - | D208 698 | And the relative indent here should be preserved too 699 | """ | @@ -314,8 +313,8 @@ D.py:698:1: D208 [*] Docstring is over-indented | 696 | And so is this, but it we should preserve the extra space on this line relative 697 | to the one before + | ^ D208 698 | And the relative indent here should be preserved too - | D208 699 | """ | = help: Remove over-indentation @@ -333,9 +332,9 @@ D.py:698:1: D208 [*] Docstring is over-indented D.py:704:1: D208 [*] Docstring is over-indented | 702 | """Summary. -703 | +703 | + | ^ D208 704 | This is overindented - | D208 705 | And so is this, but it we should preserve the extra space on this line relative 706 | This is overindented | @@ -354,8 +353,8 @@ D.py:704:1: D208 [*] Docstring is over-indented D.py:705:1: D208 [*] Docstring is over-indented | 704 | This is overindented + | ^ D208 705 | And so is this, but it we should preserve the extra space on this line relative - | D208 706 | This is overindented 707 | This is overindented | @@ -375,8 +374,8 @@ D.py:706:1: D208 [*] Docstring is over-indented | 704 | This is overindented 705 | And so is this, but it we should preserve the extra space on this line relative + | ^ D208 706 | This is overindented - | D208 707 | This is overindented 708 | """ | @@ -396,8 +395,8 @@ D.py:707:1: D208 [*] Docstring is over-indented | 705 | And so is this, but it we should preserve the extra space on this line relative 706 | This is overindented + | ^ D208 707 | This is overindented - | D208 708 | """ | = help: Remove over-indentation @@ -415,9 +414,9 @@ D.py:707:1: D208 [*] Docstring is over-indented D.py:723:1: D208 [*] Docstring is over-indented | 721 | """There's a non-breaking space (2-bytes) after 3 spaces (https://github.com/astral-sh/ruff/issues/9080). -722 | +722 | + | ^ D208 723 |     Returns: - | D208 724 | """ | = help: Remove over-indentation diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D208.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D208.py.snap index da42cdc858db4..55bacf51e3294 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D208.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D208.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- D208.py:2:1: D208 [*] Docstring is over-indented | 1 | """ + | ^ D208 2 | Author - | D208 3 | """ | = help: Remove over-indentation @@ -23,8 +22,8 @@ D208.py:8:1: D208 [*] Docstring is over-indented | 6 | class Platform: 7 | """ Remove sampler + | ^ D208 8 | Args: - | D208 9 |     Returns: 10 | """ | @@ -44,8 +43,8 @@ D208.py:9:1: D208 [*] Docstring is over-indented | 7 | """ Remove sampler 8 | Args: + | ^ D208 9 |     Returns: - | D208 10 | """ | = help: Remove over-indentation @@ -64,8 +63,8 @@ D208.py:10:1: D208 [*] Docstring is over-indented | 8 | Args: 9 |     Returns: + | ^ D208 10 | """ - | D208 | = help: Remove over-indentation @@ -83,8 +82,8 @@ D208.py:24:1: D208 [*] Docstring is over-indented | 22 | Args: 23 | Returns: + | ^ D208 24 | """ - | D208 | = help: Remove over-indentation @@ -102,8 +101,8 @@ D208.py:29:1: D208 [*] Docstring is over-indented | 27 | class Platform: 28 | """All lines are over indented including the last containing the closing quotes + | ^ D208 29 | Args: - | D208 30 | Returns: 31 | """ | @@ -123,8 +122,8 @@ D208.py:30:1: D208 [*] Docstring is over-indented | 28 | """All lines are over indented including the last containing the closing quotes 29 | Args: + | ^ D208 30 | Returns: - | D208 31 | """ | = help: Remove over-indentation @@ -143,9 +142,9 @@ D208.py:31:1: D208 [*] Docstring is over-indented | 29 | Args: 30 | Returns: + | ^ D208 31 | """ - | D208 -32 | +32 | 33 | class Platform: | = help: Remove over-indentation @@ -164,8 +163,8 @@ D208.py:35:1: D208 [*] Docstring is over-indented | 33 | class Platform: 34 | """All lines are over indented including the last + | ^ D208 35 | Args: - | D208 36 | Returns""" | = help: Remove over-indentation @@ -184,9 +183,9 @@ D208.py:36:1: D208 [*] Docstring is over-indented | 34 | """All lines are over indented including the last 35 | Args: + | ^ D208 36 | Returns""" - | D208 -37 | +37 | 38 | # OK: This doesn't get flagged because it is accepted when the closing quotes are on a separate line (see next test). Raises D209 | = help: Remove over-indentation diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2502_bidirectional_unicode.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2502_bidirectional_unicode.py.snap index abf55695ccd2d..8d11a86388ed4 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2502_bidirectional_unicode.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2502_bidirectional_unicode.py.snap @@ -1,42 +1,41 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- bidirectional_unicode.py:2:1: PLE2502 Contains control characters that can permit obfuscated code | -1 | # E2502 -2 | / print("שלום‬") -3 | | - | |_^ PLE2502 -4 | # E2502 -5 | example = "x‏" * 100 # "‏x" is assigned +1 | # E2502 +2 | print("שלום") + | ^^^^^^^^^^^^^ PLE2502 +3 | +4 | # E2502 +5 | example = "x‏" * 100 # "‏x" is assigned | bidirectional_unicode.py:5:1: PLE2502 Contains control characters that can permit obfuscated code | -4 | # E2502 -5 | / example = "x‏" * 100 # "‏x" is assigned -6 | | - | |_^ PLE2502 -7 | # E2502 -8 | if access_level != "none‮⁦": # Check if admin ⁩⁦' and access_level != 'user +4 | # E2502 +5 | example = "x‏" * 100 # "‏x" is assigned + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE2502 +6 | +7 | # E2502 +8 | if access_level != "none": # Check if admin ' and access_level != 'user | bidirectional_unicode.py:8:1: PLE2502 Contains control characters that can permit obfuscated code | -7 | # E2502 -8 | / if access_level != "none‮⁦": # Check if admin ⁩⁦' and access_level != 'user -9 | | print("You are an admin.") - | |_^ PLE2502 +7 | # E2502 +8 | if access_level != "none": # Check if admin ' and access_level != 'user + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE2502 +9 | print("You are an admin.") | bidirectional_unicode.py:14:1: PLE2502 Contains control characters that can permit obfuscated code | -12 | # E2502 -13 | def subtract_funds(account: str, amount: int): -14 | / """Subtract funds from bank account then ⁧""" -15 | | return - | |_^ PLE2502 -16 | bank[account] -= amount -17 | return +12 | # E2502 +13 | def subtract_funds(account: str, amount: int): +14 | """Subtract funds from bank account then """ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE2502 +15 | return +16 | bank[account] -= amount +17 | return | diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__import_sorting.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__import_sorting.snap index 7f726c2783a91..59672d19b8bc5 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__import_sorting.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__import_sorting.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/linter.rs -snapshot_kind: text --- isort.ipynb:cell 1:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from pathlib import Path 2 | | import random 3 | | import math -4 | | from typing import Any - | |_^ I001 + | |____________^ I001 +4 | from typing import Any 5 | import collections 6 | # Newline should be added here | @@ -28,8 +27,8 @@ isort.ipynb:cell 2:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from typing import Any 2 | | import collections -3 | | # Newline should be added here - | |_^ I001 + | |___________________^ I001 +3 | # Newline should be added here 4 | def foo(): 5 | pass | @@ -52,9 +51,9 @@ isort.ipynb:cell 3:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from pathlib import Path 2 | | import sys -3 | | -4 | | %matplotlib \ - | |_^ I001 +3 | | + | |__^ I001 +4 | %matplotlib \ 5 | --inline | = help: Organize imports @@ -73,9 +72,10 @@ isort.ipynb:cell 3:1:1: I001 [*] Import block is un-sorted or un-formatted isort.ipynb:cell 3:7:1: I001 [*] Import block is un-sorted or un-formatted | 5 | --inline -6 | +6 | 7 | / import math 8 | | import abc + | |___________^ I001 | = help: Organize imports diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__fstring_format_spec_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__fstring_format_spec_1.py.snap index 8cb0b79749cb5..dbc237b1d3ac0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__fstring_format_spec_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__fstring_format_spec_1.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/re_lexing/fstring_format_spec_1.py -snapshot_kind: text --- ## AST @@ -301,7 +300,7 @@ Module( 5 | f'middle {'string':\ 6 | 'format spec'} | ^ Syntax Error: f-string: expecting '}' -7 | +7 | 8 | f'middle {'string':\\ | @@ -310,7 +309,7 @@ Module( 5 | f'middle {'string':\ 6 | 'format spec'} | ^^^^^^ Syntax Error: Simple statements must be separated by newlines or semicolons -7 | +7 | 8 | f'middle {'string':\\ | @@ -319,7 +318,7 @@ Module( 5 | f'middle {'string':\ 6 | 'format spec'} | ^^^^ Syntax Error: Simple statements must be separated by newlines or semicolons -7 | +7 | 8 | f'middle {'string':\\ | @@ -328,7 +327,7 @@ Module( 5 | f'middle {'string':\ 6 | 'format spec'} | ^^ Syntax Error: missing closing quote in string literal -7 | +7 | 8 | f'middle {'string':\\ | @@ -337,7 +336,7 @@ Module( 5 | f'middle {'string':\ 6 | 'format spec'} | ^ Syntax Error: Expected a statement -7 | +7 | 8 | f'middle {'string':\\ 9 | 'format spec'} | @@ -345,9 +344,9 @@ Module( | 6 | 'format spec'} -7 | +7 | 8 | f'middle {'string':\\ - | Syntax Error: f-string: unterminated string + | ^ Syntax Error: f-string: unterminated string 9 | 'format spec'} | @@ -356,7 +355,7 @@ Module( 8 | f'middle {'string':\\ 9 | 'format spec'} | ^^^^^^^^ Syntax Error: Unexpected indentation -10 | +10 | 11 | f'middle {'string':\\\ | @@ -365,7 +364,7 @@ Module( 8 | f'middle {'string':\\ 9 | 'format spec'} | ^ Syntax Error: Expected a statement -10 | +10 | 11 | f'middle {'string':\\\ | @@ -374,7 +373,7 @@ Module( 8 | f'middle {'string':\\ 9 | 'format spec'} | ^ Syntax Error: Expected a statement -10 | +10 | 11 | f'middle {'string':\\\ 12 | 'format spec'} | @@ -382,9 +381,9 @@ Module( | 9 | 'format spec'} -10 | +10 | + | ^ Syntax Error: Expected a statement 11 | f'middle {'string':\\\ - | Syntax Error: Expected a statement 12 | 'format spec'} | @@ -420,5 +419,5 @@ Module( | 11 | f'middle {'string':\\\ 12 | 'format spec'} - | Syntax Error: Expected a statement + | ^ Syntax Error: Expected a statement | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_indent.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_indent.py.snap index 4c589dda56cf5..76a3ff101f677 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_indent.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_indent.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/statements/if_extra_indent.py -snapshot_kind: text --- ## AST @@ -92,14 +91,14 @@ Module( 3 | pass 4 | a + b | ^^^^^^^^ Syntax Error: Unexpected indentation -5 | +5 | 6 | pass | | 6 | pass -7 | +7 | + | ^ Syntax Error: Expected a statement 8 | a = 10 - | Syntax Error: Expected a statement | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_misspelled_except.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_misspelled_except.py.snap index 4180af03110d8..93dc9f223d15a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_misspelled_except.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_misspelled_except.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/inline/err/try_stmt_misspelled_except.py -snapshot_kind: text --- ## AST @@ -198,8 +197,8 @@ Module( | 3 | exept: # spellchecker:disable-line 4 | pass + | ^ Syntax Error: Expected a statement 5 | finally: - | Syntax Error: Expected a statement 6 | pass 7 | a = 1 | @@ -239,8 +238,8 @@ Module( | 5 | finally: 6 | pass + | ^ Syntax Error: Expected a statement 7 | a = 1 - | Syntax Error: Expected a statement 8 | try: 9 | pass | @@ -268,6 +267,6 @@ Module( | 12 | exept: # spellchecker:disable-line 13 | pass + | ^ Syntax Error: Expected a statement 14 | b = 1 - | Syntax Error: Expected a statement | From 9436894220baf7a31eaf2debc83eba5575fd15c0 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Wed, 8 Jan 2025 09:58:31 -0500 Subject: [PATCH 11/18] test: another set of updates related to line terminator handling This group of updates is similar to the last one, but they call out the fact that while the change is an improvement, it does still seem to be a little buggy. As one example, previously we would have this: | 1 | / from __future__ import annotations 2 | | 3 | | from typing import Any 4 | | 5 | | from requests import Session 6 | | 7 | | from my_first_party import my_first_party_object 8 | | 9 | | from . import my_local_folder_object 10 | | 11 | | 12 | | 13 | | class Thing(object): | |_^ I001 14 | name: str 15 | def __init__(self, name: str): | = help: Organize imports And now here's what it looks like after: | 1 | / from __future__ import annotations 2 | | 3 | | from typing import Any 4 | | 5 | | from requests import Session 6 | | 7 | | from my_first_party import my_first_party_object 8 | | 9 | | from . import my_local_folder_object 10 | | 11 | | 12 | | | |__^ Organize imports 13 | class Thing(object): 14 | name: str 15 | def __init__(self, name: str): | = help: Organize imports So at least now, the diagnostic is not pointing to a completely unrelated thing (`class Thing`), but it's still not quite pointing to the imports directly. And the `^` is a bit offset. After looking at some examples more closely, I think this is probably more of a bug with how we're generating offsets, since we are actually pointing to a location that is a few empty lines _below_ the last import. And `annotate-snippets` is rendering that part correctly. However, the offset from the left (the `^` is pointing at `r` instead of `f` or even at the end of `from . import my_local_folder_object`) appears to be a problem with `annotate-snippets` itself. We accept this under the reasoning that it's an improvement, albeit not perfect. --- ...isort__tests__lines_after_imports.pyi.snap | 19 ++++---- ...ts__lines_after_imports_func_after.py.snap | 35 ++++++++------- ...after_imports_lines_after_imports.pyi.snap | 19 ++++---- ...rts_lines_after_imports_func_after.py.snap | 35 ++++++++------- ...__tests__sections_main_first_party.py.snap | 11 +++-- ...es__isort__tests__trailing_comment.py.snap | 42 +++++++++--------- ...nter__rules__isort__tests__unicode.py.snap | 7 ++- ...patibility-lines-after(-1)-between(0).snap | 43 +++++++++---------- ...mpatibility-lines-after(0)-between(0).snap | 41 +++++++++--------- ...mpatibility-lines-after(1)-between(1).snap | 35 ++++++++------- ...mpatibility-lines-after(4)-between(4).snap | 43 +++++++++---------- ..._tests__blank_lines_typing_stub_isort.snap | 33 +++++++------- ...tyle__tests__preview__W391_W391.ipynb.snap | 34 +++++++-------- ...patibility-lines-after(-1)-between(0).snap | 37 ++++++++-------- ...mpatibility-lines-after(0)-between(0).snap | 39 ++++++++--------- ...mpatibility-lines-after(1)-between(1).snap | 31 +++++++------ ...mpatibility-lines-after(4)-between(4).snap | 37 ++++++++-------- 17 files changed, 263 insertions(+), 278 deletions(-) diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports.pyi.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports.pyi.snap index 28f192ce47d07..815f640a103ce 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports.pyi.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports.pyi.snap @@ -1,23 +1,22 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- lines_after_imports.pyi:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from __future__ import annotations - 2 | | + 2 | | 3 | | from typing import Any - 4 | | + 4 | | 5 | | from requests import Session - 6 | | + 6 | | 7 | | from my_first_party import my_first_party_object - 8 | | + 8 | | 9 | | from . import my_local_folder_object -10 | | -11 | | -12 | | -13 | | class Thing(object): - | |_^ I001 +10 | | +11 | | +12 | | + | |__^ I001 +13 | class Thing(object): 14 | name: str 15 | def __init__(self, name: str): | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_func_after.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_func_after.py.snap index 4c84e821e92b8..75a3dabea69f1 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_func_after.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_func_after.py.snap @@ -1,31 +1,30 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- lines_after_imports_func_after.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from __future__ import annotations - 2 | | + 2 | | 3 | | from typing import Any - 4 | | + 4 | | 5 | | from requests import Session - 6 | | + 6 | | 7 | | from my_first_party import my_first_party_object - 8 | | + 8 | | 9 | | from . import my_local_folder_object -10 | | -11 | | -12 | | -13 | | -14 | | -15 | | -16 | | -17 | | -18 | | -19 | | -20 | | -21 | | def main(): - | |_^ I001 +10 | | +11 | | +12 | | +13 | | +14 | | +15 | | +16 | | +17 | | +18 | | +19 | | +20 | | + | |__^ I001 +21 | def main(): 22 | my_local_folder_object.get() | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports.pyi.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports.pyi.snap index 28f192ce47d07..815f640a103ce 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports.pyi.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports.pyi.snap @@ -1,23 +1,22 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- lines_after_imports.pyi:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from __future__ import annotations - 2 | | + 2 | | 3 | | from typing import Any - 4 | | + 4 | | 5 | | from requests import Session - 6 | | + 6 | | 7 | | from my_first_party import my_first_party_object - 8 | | + 8 | | 9 | | from . import my_local_folder_object -10 | | -11 | | -12 | | -13 | | class Thing(object): - | |_^ I001 +10 | | +11 | | +12 | | + | |__^ I001 +13 | class Thing(object): 14 | name: str 15 | def __init__(self, name: str): | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_func_after.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_func_after.py.snap index b6a001790b21c..46f737f9f4f87 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_func_after.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_func_after.py.snap @@ -1,31 +1,30 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- lines_after_imports_func_after.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / from __future__ import annotations - 2 | | + 2 | | 3 | | from typing import Any - 4 | | + 4 | | 5 | | from requests import Session - 6 | | + 6 | | 7 | | from my_first_party import my_first_party_object - 8 | | + 8 | | 9 | | from . import my_local_folder_object -10 | | -11 | | -12 | | -13 | | -14 | | -15 | | -16 | | -17 | | -18 | | -19 | | -20 | | -21 | | def main(): - | |_^ I001 +10 | | +11 | | +12 | | +13 | | +14 | | +15 | | +16 | | +17 | | +18 | | +19 | | +20 | | + | |__^ I001 +21 | def main(): 22 | my_local_folder_object.get() | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_main_first_party.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_main_first_party.py.snap index 406b339a5beef..db6abd2dde404 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_main_first_party.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_main_first_party.py.snap @@ -1,18 +1,17 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- main_first_party.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / import os - 2 | | + 2 | | 3 | | import __main__ 4 | | import third_party - 5 | | + 5 | | 6 | | import first_party - 7 | | - 8 | | os.a - | |_^ I001 + 7 | | + | |__^ I001 + 8 | os.a 9 | third_party.a 10 | __main__.a | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__trailing_comment.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__trailing_comment.py.snap index bd84df4794911..c0decdf28ba17 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__trailing_comment.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__trailing_comment.py.snap @@ -1,21 +1,20 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- trailing_comment.py:8:1: I001 [*] Import block is un-sorted or un-formatted | 6 | pass - 7 | + 7 | 8 | / from mylib import ( 9 | | MyClient, 10 | | MyMgmtClient, 11 | | ); from foo import ( 12 | | bar 13 | | )# some comment -14 | | -15 | | pass - | |_^ I001 -16 | +14 | | + | |__^ I001 +15 | pass +16 | 17 | from foo import ( | = help: Organize imports @@ -39,7 +38,7 @@ trailing_comment.py:8:1: I001 [*] Import block is un-sorted or un-formatted trailing_comment.py:17:1: I001 [*] Import block is un-sorted or un-formatted | 15 | pass -16 | +16 | 17 | / from foo import ( 18 | | bar 19 | | ) @@ -48,10 +47,10 @@ trailing_comment.py:17:1: I001 [*] Import block is un-sorted or un-formatted 22 | | MyMgmtClient, 23 | | # some comment 24 | | ) -25 | | -26 | | pass - | |_^ I001 -27 | +25 | | + | |__^ I001 +26 | pass +27 | 28 | from mylib import ( | = help: Organize imports @@ -71,15 +70,15 @@ trailing_comment.py:17:1: I001 [*] Import block is un-sorted or un-formatted trailing_comment.py:35:1: I001 [*] Import block is un-sorted or un-formatted | 33 | pass -34 | +34 | 35 | / from mylib import ( 36 | | MyClient 37 | | # some comment 38 | | ) -39 | | -40 | | pass - | |_^ I001 -41 | +39 | | + | |__^ I001 +40 | pass +41 | 42 | from mylib import ( | = help: Organize imports @@ -100,15 +99,15 @@ trailing_comment.py:35:1: I001 [*] Import block is un-sorted or un-formatted trailing_comment.py:42:1: I001 [*] Import block is un-sorted or un-formatted | 40 | pass -41 | +41 | 42 | / from mylib import ( 43 | | # some comment 44 | | MyClient 45 | | ) -46 | | -47 | | pass - | |_^ I001 -48 | +46 | | + | |__^ I001 +47 | pass +48 | 49 | # a | = help: Organize imports @@ -134,6 +133,7 @@ trailing_comment.py:50:1: I001 [*] Import block is un-sorted or un-formatted 52 | | MyClient # d 53 | | # e 54 | | ) # f + | |______^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__unicode.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__unicode.py.snap index 66ca24d01332d..66263fbc0bf9e 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__unicode.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__unicode.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- unicode.py:1:1: I001 [*] Import block is un-sorted or un-formatted | @@ -8,9 +7,9 @@ unicode.py:1:1: I001 [*] Import block is un-sorted or un-formatted 2 | | from numpy import pi as π 3 | | import numpy as ℂℇℊℋℌℍℎℐℑℒℓℕℤΩℨKÅℬℭℯℰℱℹℴ 4 | | import numpy as CƐgHHHhIILlNZΩZKÅBCeEFio -5 | | -6 | | h = 2 * π * ℏ - | |_^ I001 +5 | | + | |__^ I001 +6 | h = 2 * π * ℏ | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(-1)-between(0).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(-1)-between(0).snap index 3fdd8bbb257fd..21756fb7ebeee 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(-1)-between(0).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(-1)-between(0).snap @@ -1,18 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / import json -2 | | -3 | | -4 | | +2 | | +3 | | +4 | | 5 | | from typing import Any, Sequence -6 | | -7 | | -8 | | class MissingCommand(TypeError): ... # noqa: N818 - | |_^ I001 +6 | | +7 | | + | |__^ I001 +8 | class MissingCommand(TypeError): ... # noqa: N818 | = help: Organize imports @@ -28,10 +27,10 @@ E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted E30_isort.py:23:1: E302 [*] Expected 2 blank lines, found 1 | 21 | abcd.foo() -22 | +22 | 23 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... | ^^^ E302 -24 | +24 | 25 | if TYPE_CHECKING: | = help: Add missing blank line(s) @@ -49,13 +48,13 @@ E30_isort.py:26:1: I001 [*] Import block is un-sorted or un-formatted | 25 | if TYPE_CHECKING: 26 | / import os -27 | | -28 | | -29 | | +27 | | +28 | | +29 | | 30 | | from typing_extensions import TypeAlias -31 | | - | |_^ I001 -32 | + | |____________________________________________^ I001 +31 | +32 | 33 | abcd.foo() | = help: Organize imports @@ -73,7 +72,7 @@ E30_isort.py:26:1: I001 [*] Import block is un-sorted or un-formatted E30_isort.py:35:1: E302 [*] Expected 2 blank lines, found 1 | 33 | abcd.foo() -34 | +34 | 35 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: | ^^^ E302 36 | ... @@ -92,7 +91,7 @@ E30_isort.py:35:1: E302 [*] Expected 2 blank lines, found 1 E30_isort.py:41:1: E302 [*] Expected 2 blank lines, found 1 | 39 | from typing_extensions import TypeAlias -40 | +40 | 41 | def __call__2(self, name: str, *args: Any, **kwargs: Any) -> Any: | ^^^ E302 42 | ... @@ -111,9 +110,9 @@ E30_isort.py:41:1: E302 [*] Expected 2 blank lines, found 1 E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted | 60 | / from typing import Any, Sequence -61 | | -62 | | class MissingCommand(TypeError): ... # noqa: N818 - | |_^ I001 +61 | | + | |__^ I001 +62 | class MissingCommand(TypeError): ... # noqa: N818 | = help: Organize imports @@ -127,7 +126,7 @@ E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted E30_isort.py:62:1: E302 [*] Expected 2 blank lines, found 1 | 60 | from typing import Any, Sequence -61 | +61 | 62 | class MissingCommand(TypeError): ... # noqa: N818 | ^^^^^ E302 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(0)-between(0).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(0)-between(0).snap index 9858c0e61f194..a74c8108feae4 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(0)-between(0).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(0)-between(0).snap @@ -1,18 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / import json -2 | | -3 | | -4 | | +2 | | +3 | | +4 | | 5 | | from typing import Any, Sequence -6 | | -7 | | -8 | | class MissingCommand(TypeError): ... # noqa: N818 - | |_^ I001 +6 | | +7 | | + | |__^ I001 +8 | class MissingCommand(TypeError): ... # noqa: N818 | = help: Organize imports @@ -31,10 +30,10 @@ E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted E30_isort.py:23:1: E302 [*] Expected 2 blank lines, found 1 | 21 | abcd.foo() -22 | +22 | 23 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... | ^^^ E302 -24 | +24 | 25 | if TYPE_CHECKING: | = help: Add missing blank line(s) @@ -52,13 +51,13 @@ E30_isort.py:26:1: I001 [*] Import block is un-sorted or un-formatted | 25 | if TYPE_CHECKING: 26 | / import os -27 | | -28 | | -29 | | +27 | | +28 | | +29 | | 30 | | from typing_extensions import TypeAlias -31 | | - | |_^ I001 -32 | + | |____________________________________________^ I001 +31 | +32 | 33 | abcd.foo() | = help: Organize imports @@ -76,7 +75,7 @@ E30_isort.py:26:1: I001 [*] Import block is un-sorted or un-formatted E30_isort.py:35:1: E302 [*] Expected 2 blank lines, found 1 | 33 | abcd.foo() -34 | +34 | 35 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: | ^^^ E302 36 | ... @@ -95,7 +94,7 @@ E30_isort.py:35:1: E302 [*] Expected 2 blank lines, found 1 E30_isort.py:41:1: E302 [*] Expected 2 blank lines, found 1 | 39 | from typing_extensions import TypeAlias -40 | +40 | 41 | def __call__2(self, name: str, *args: Any, **kwargs: Any) -> Any: | ^^^ E302 42 | ... @@ -114,9 +113,9 @@ E30_isort.py:41:1: E302 [*] Expected 2 blank lines, found 1 E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted | 60 | / from typing import Any, Sequence -61 | | -62 | | class MissingCommand(TypeError): ... # noqa: N818 - | |_^ I001 +61 | | + | |__^ I001 +62 | class MissingCommand(TypeError): ... # noqa: N818 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(1)-between(1).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(1)-between(1).snap index 1df526f6d333f..3dbb72872d2d6 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(1)-between(1).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(1)-between(1).snap @@ -1,18 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / import json -2 | | -3 | | -4 | | +2 | | +3 | | +4 | | 5 | | from typing import Any, Sequence -6 | | -7 | | -8 | | class MissingCommand(TypeError): ... # noqa: N818 - | |_^ I001 +6 | | +7 | | + | |__^ I001 +8 | class MissingCommand(TypeError): ... # noqa: N818 | = help: Organize imports @@ -30,10 +29,10 @@ E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted E30_isort.py:23:1: E302 [*] Expected 2 blank lines, found 1 | 21 | abcd.foo() -22 | +22 | 23 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... | ^^^ E302 -24 | +24 | 25 | if TYPE_CHECKING: | = help: Add missing blank line(s) @@ -51,13 +50,13 @@ E30_isort.py:26:1: I001 [*] Import block is un-sorted or un-formatted | 25 | if TYPE_CHECKING: 26 | / import os -27 | | -28 | | -29 | | +27 | | +28 | | +29 | | 30 | | from typing_extensions import TypeAlias -31 | | - | |_^ I001 -32 | + | |____________________________________________^ I001 +31 | +32 | 33 | abcd.foo() | = help: Organize imports @@ -75,7 +74,7 @@ E30_isort.py:26:1: I001 [*] Import block is un-sorted or un-formatted E30_isort.py:35:1: E302 [*] Expected 2 blank lines, found 1 | 33 | abcd.foo() -34 | +34 | 35 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: | ^^^ E302 36 | ... @@ -94,7 +93,7 @@ E30_isort.py:35:1: E302 [*] Expected 2 blank lines, found 1 E30_isort.py:41:1: E302 [*] Expected 2 blank lines, found 1 | 39 | from typing_extensions import TypeAlias -40 | +40 | 41 | def __call__2(self, name: str, *args: Any, **kwargs: Any) -> Any: | ^^^ E302 42 | ... diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(4)-between(4).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(4)-between(4).snap index ff3b53cc1a837..b894647b71b38 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(4)-between(4).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(4)-between(4).snap @@ -1,18 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / import json -2 | | -3 | | -4 | | +2 | | +3 | | +4 | | 5 | | from typing import Any, Sequence -6 | | -7 | | -8 | | class MissingCommand(TypeError): ... # noqa: N818 - | |_^ I001 +6 | | +7 | | + | |__^ I001 +8 | class MissingCommand(TypeError): ... # noqa: N818 | = help: Organize imports @@ -50,10 +49,10 @@ E30_isort.py:8:1: E302 [*] Expected 4 blank lines, found 2 E30_isort.py:23:1: E302 [*] Expected 2 blank lines, found 1 | 21 | abcd.foo() -22 | +22 | 23 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... | ^^^ E302 -24 | +24 | 25 | if TYPE_CHECKING: | = help: Add missing blank line(s) @@ -71,13 +70,13 @@ E30_isort.py:26:1: I001 [*] Import block is un-sorted or un-formatted | 25 | if TYPE_CHECKING: 26 | / import os -27 | | -28 | | -29 | | +27 | | +28 | | +29 | | 30 | | from typing_extensions import TypeAlias -31 | | - | |_^ I001 -32 | + | |____________________________________________^ I001 +31 | +32 | 33 | abcd.foo() | = help: Organize imports @@ -95,7 +94,7 @@ E30_isort.py:26:1: I001 [*] Import block is un-sorted or un-formatted E30_isort.py:35:1: E302 [*] Expected 2 blank lines, found 1 | 33 | abcd.foo() -34 | +34 | 35 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: | ^^^ E302 36 | ... @@ -114,7 +113,7 @@ E30_isort.py:35:1: E302 [*] Expected 2 blank lines, found 1 E30_isort.py:41:1: E302 [*] Expected 2 blank lines, found 1 | 39 | from typing_extensions import TypeAlias -40 | +40 | 41 | def __call__2(self, name: str, *args: Any, **kwargs: Any) -> Any: | ^^^ E302 42 | ... @@ -133,9 +132,9 @@ E30_isort.py:41:1: E302 [*] Expected 2 blank lines, found 1 E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted | 60 | / from typing import Any, Sequence -61 | | -62 | | class MissingCommand(TypeError): ... # noqa: N818 - | |_^ I001 +61 | | + | |__^ I001 +62 | class MissingCommand(TypeError): ... # noqa: N818 | = help: Organize imports @@ -151,7 +150,7 @@ E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted E30_isort.py:62:1: E302 [*] Expected 4 blank lines, found 1 | 60 | from typing import Any, Sequence -61 | +61 | 62 | class MissingCommand(TypeError): ... # noqa: N818 | ^^^^^ E302 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_typing_stub_isort.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_typing_stub_isort.snap index 67a4e6ccca5a5..af6b6e35f4476 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_typing_stub_isort.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_typing_stub_isort.snap @@ -1,18 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E30_isort.pyi:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / import json -2 | | -3 | | -4 | | +2 | | +3 | | +4 | | 5 | | from typing import Any, Sequence -6 | | -7 | | -8 | | class MissingCommand(TypeError): ... # noqa: N818 - | |_^ I001 +6 | | +7 | | + | |__^ I001 +8 | class MissingCommand(TypeError): ... # noqa: N818 | = help: Organize imports @@ -98,7 +97,7 @@ E30_isort.pyi:21:5: E303 [*] Too many blank lines (2) | 21 | abcd.foo() | ^^^^ E303 -22 | +22 | 23 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... | = help: Remove extraneous blank line(s) @@ -116,13 +115,13 @@ E30_isort.pyi:26:1: I001 [*] Import block is un-sorted or un-formatted | 25 | if TYPE_CHECKING: 26 | / import os -27 | | -28 | | -29 | | +27 | | +28 | | +29 | | 30 | | from typing_extensions import TypeAlias -31 | | - | |_^ I001 -32 | + | |____________________________________________^ I001 +31 | +32 | 33 | abcd.foo() | = help: Organize imports @@ -158,7 +157,7 @@ E30_isort.pyi:33:5: E303 [*] Too many blank lines (2) | 33 | abcd.foo() | ^^^^ E303 -34 | +34 | 35 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: | = help: Remove extraneous blank line(s) @@ -256,7 +255,7 @@ E30_isort.pyi:60:1: E303 [*] Too many blank lines (2) | 60 | from typing import Any, Sequence | ^^^^ E303 -61 | +61 | 62 | class MissingCommand(TypeError): ... # noqa: N818 | = help: Remove extraneous blank line(s) diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391.ipynb.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391.ipynb.snap index 94ec2ac5c16ce..898237e9b4839 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391.ipynb.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391.ipynb.snap @@ -5,11 +5,11 @@ W391.ipynb:5:1: W391 [*] Too many newlines at end of cell | 3 | # just a comment in this cell 4 | # a comment and some newlines - 5 | / - 6 | | - 7 | | - 8 | | - | |_^ W391 + 5 | / + 6 | | + 7 | | + | |__^ W391 + 8 | 9 | 1 + 1 10 | # a comment | @@ -30,12 +30,12 @@ W391.ipynb:11:1: W391 [*] Too many newlines at end of cell | 9 | 1 + 1 10 | # a comment -11 | / -12 | | -13 | | -14 | | -15 | | - | |_^ W391 +11 | / +12 | | +13 | | +14 | | + | |__^ W391 +15 | 16 | 1+1 | = help: Remove trailing newlines @@ -55,12 +55,12 @@ W391.ipynb:11:1: W391 [*] Too many newlines at end of cell W391.ipynb:17:1: W391 [*] Too many newlines at end of cell | 16 | 1+1 -17 | / -18 | | -19 | | -20 | | -21 | | - | |_^ W391 +17 | / +18 | | +19 | | +20 | | + | |__^ W391 +21 | | = help: Remove trailing newlines diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(-1)-between(0).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(-1)-between(0).snap index bb2fe177c62d8..03fe8c1308d3e 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(-1)-between(0).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(-1)-between(0).snap @@ -1,18 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / import json -2 | | -3 | | -4 | | +2 | | +3 | | +4 | | 5 | | from typing import Any, Sequence -6 | | -7 | | -8 | | class MissingCommand(TypeError): ... # noqa: N818 - | |_^ I001 +6 | | +7 | | + | |__^ I001 +8 | class MissingCommand(TypeError): ... # noqa: N818 | = help: Organize imports @@ -45,7 +44,7 @@ E30_isort.py:21:5: E303 [*] Too many blank lines (2) | 21 | abcd.foo() | ^^^^ E303 -22 | +22 | 23 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... | = help: Remove extraneous blank line(s) @@ -63,13 +62,13 @@ E30_isort.py:26:1: I001 [*] Import block is un-sorted or un-formatted | 25 | if TYPE_CHECKING: 26 | / import os -27 | | -28 | | -29 | | +27 | | +28 | | +29 | | 30 | | from typing_extensions import TypeAlias -31 | | - | |_^ I001 -32 | + | |____________________________________________^ I001 +31 | +32 | 33 | abcd.foo() | = help: Organize imports @@ -105,7 +104,7 @@ E30_isort.py:33:5: E303 [*] Too many blank lines (2) | 33 | abcd.foo() | ^^^^ E303 -34 | +34 | 35 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: | = help: Remove extraneous blank line(s) @@ -122,9 +121,9 @@ E30_isort.py:33:5: E303 [*] Too many blank lines (2) E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted | 60 | / from typing import Any, Sequence -61 | | -62 | | class MissingCommand(TypeError): ... # noqa: N818 - | |_^ I001 +61 | | + | |__^ I001 +62 | class MissingCommand(TypeError): ... # noqa: N818 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(0)-between(0).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(0)-between(0).snap index cc904502afa29..4fd3cf8aed585 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(0)-between(0).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(0)-between(0).snap @@ -1,18 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / import json -2 | | -3 | | -4 | | +2 | | +3 | | +4 | | 5 | | from typing import Any, Sequence -6 | | -7 | | -8 | | class MissingCommand(TypeError): ... # noqa: N818 - | |_^ I001 +6 | | +7 | | + | |__^ I001 +8 | class MissingCommand(TypeError): ... # noqa: N818 | = help: Organize imports @@ -65,7 +64,7 @@ E30_isort.py:21:5: E303 [*] Too many blank lines (2) | 21 | abcd.foo() | ^^^^ E303 -22 | +22 | 23 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... | = help: Remove extraneous blank line(s) @@ -83,13 +82,13 @@ E30_isort.py:26:1: I001 [*] Import block is un-sorted or un-formatted | 25 | if TYPE_CHECKING: 26 | / import os -27 | | -28 | | -29 | | +27 | | +28 | | +29 | | 30 | | from typing_extensions import TypeAlias -31 | | - | |_^ I001 -32 | + | |____________________________________________^ I001 +31 | +32 | 33 | abcd.foo() | = help: Organize imports @@ -125,7 +124,7 @@ E30_isort.py:33:5: E303 [*] Too many blank lines (2) | 33 | abcd.foo() | ^^^^ E303 -34 | +34 | 35 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: | = help: Remove extraneous blank line(s) @@ -142,9 +141,9 @@ E30_isort.py:33:5: E303 [*] Too many blank lines (2) E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted | 60 | / from typing import Any, Sequence -61 | | -62 | | class MissingCommand(TypeError): ... # noqa: N818 - | |_^ I001 +61 | | + | |__^ I001 +62 | class MissingCommand(TypeError): ... # noqa: N818 | = help: Organize imports @@ -158,7 +157,7 @@ E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted E30_isort.py:62:1: E303 [*] Too many blank lines (1) | 60 | from typing import Any, Sequence -61 | +61 | 62 | class MissingCommand(TypeError): ... # noqa: N818 | ^^^^^ E303 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(1)-between(1).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(1)-between(1).snap index e4ca5f4408b2a..2d8da6c2e2f99 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(1)-between(1).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(1)-between(1).snap @@ -1,18 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / import json -2 | | -3 | | -4 | | +2 | | +3 | | +4 | | 5 | | from typing import Any, Sequence -6 | | -7 | | -8 | | class MissingCommand(TypeError): ... # noqa: N818 - | |_^ I001 +6 | | +7 | | + | |__^ I001 +8 | class MissingCommand(TypeError): ... # noqa: N818 | = help: Organize imports @@ -63,7 +62,7 @@ E30_isort.py:21:5: E303 [*] Too many blank lines (2) | 21 | abcd.foo() | ^^^^ E303 -22 | +22 | 23 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... | = help: Remove extraneous blank line(s) @@ -81,13 +80,13 @@ E30_isort.py:26:1: I001 [*] Import block is un-sorted or un-formatted | 25 | if TYPE_CHECKING: 26 | / import os -27 | | -28 | | -29 | | +27 | | +28 | | +29 | | 30 | | from typing_extensions import TypeAlias -31 | | - | |_^ I001 -32 | + | |____________________________________________^ I001 +31 | +32 | 33 | abcd.foo() | = help: Organize imports @@ -123,7 +122,7 @@ E30_isort.py:33:5: E303 [*] Too many blank lines (2) | 33 | abcd.foo() | ^^^^ E303 -34 | +34 | 35 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: | = help: Remove extraneous blank line(s) diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(4)-between(4).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(4)-between(4).snap index f65f231388a44..fff03e5103987 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(4)-between(4).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(4)-between(4).snap @@ -1,18 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted | 1 | / import json -2 | | -3 | | -4 | | +2 | | +3 | | +4 | | 5 | | from typing import Any, Sequence -6 | | -7 | | -8 | | class MissingCommand(TypeError): ... # noqa: N818 - | |_^ I001 +6 | | +7 | | + | |__^ I001 +8 | class MissingCommand(TypeError): ... # noqa: N818 | = help: Organize imports @@ -34,7 +33,7 @@ E30_isort.py:21:5: E303 [*] Too many blank lines (2) | 21 | abcd.foo() | ^^^^ E303 -22 | +22 | 23 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... | = help: Remove extraneous blank line(s) @@ -52,13 +51,13 @@ E30_isort.py:26:1: I001 [*] Import block is un-sorted or un-formatted | 25 | if TYPE_CHECKING: 26 | / import os -27 | | -28 | | -29 | | +27 | | +28 | | +29 | | 30 | | from typing_extensions import TypeAlias -31 | | - | |_^ I001 -32 | + | |____________________________________________^ I001 +31 | +32 | 33 | abcd.foo() | = help: Organize imports @@ -77,7 +76,7 @@ E30_isort.py:33:5: E303 [*] Too many blank lines (2) | 33 | abcd.foo() | ^^^^ E303 -34 | +34 | 35 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: | = help: Remove extraneous blank line(s) @@ -94,9 +93,9 @@ E30_isort.py:33:5: E303 [*] Too many blank lines (2) E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted | 60 | / from typing import Any, Sequence -61 | | -62 | | class MissingCommand(TypeError): ... # noqa: N818 - | |_^ I001 +61 | | + | |__^ I001 +62 | class MissingCommand(TypeError): ... # noqa: N818 | = help: Organize imports From b1c272dc1312fbc1b0b19a1dd335c5c00d988f73 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Wed, 8 Jan 2025 10:22:44 -0500 Subject: [PATCH 12/18] test: update snapshot with fixed annotation but carets include whitespace I separated out this snapshot update since the string of `^` including whitespace looked a little odd. I investigated this one specifically, and indeed, our span in this case is telling `annotate-snippets` to point at the whitespace. So this is `annotate-snippets` doing what it's told with a mildly sub-optimal span. For clarity, the before rendering is: skip.py:34:1: I001 [*] Import block is un-sorted or un-formatted | 32 | import sys; import os # isort:skip 33 | import sys; import os # isort:skip # isort:skip 34 | / import sys; import os | = help: Organize imports And now after is: skip.py:34:1: I001 [*] Import block is un-sorted or un-formatted | 32 | import sys; import os # isort:skip 33 | import sys; import os # isort:skip # isort:skip 34 | import sys; import os | ^^^^^^^^^^^^^^^^^^^^^^^^^ I001 | = help: Organize imports This is a clear bug fix since it adds in the `I001` annotation, even though the carets look a little funny by including the whitespace preceding `import sys; import os`. --- ..._linter__rules__isort__tests__skip.py.snap | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__skip.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__skip.py.snap index 3acb2d46e3a40..9befa4c450952 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__skip.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__skip.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- skip.py:20:1: I001 [*] Import block is un-sorted or un-formatted | @@ -8,9 +7,9 @@ skip.py:20:1: I001 [*] Import block is un-sorted or un-formatted 19 | import os # isort: skip 20 | / import collections 21 | | import abc -22 | | - | |_^ I001 -23 | + | |_______________^ I001 +22 | +23 | 24 | def f(): | = help: Organize imports @@ -32,9 +31,9 @@ skip.py:27:1: I001 [*] Import block is un-sorted or un-formatted 26 | import os # isort:skip 27 | / import collections 28 | | import abc -29 | | - | |_^ I001 -30 | + | |_______________^ I001 +29 | +30 | 31 | def f(): | = help: Organize imports @@ -52,9 +51,10 @@ skip.py:27:1: I001 [*] Import block is un-sorted or un-formatted skip.py:34:1: I001 [*] Import block is un-sorted or un-formatted | -32 | import sys; import os # isort:skip -33 | import sys; import os # isort:skip # isort:skip -34 | / import sys; import os +32 | import sys; import os # isort:skip +33 | import sys; import os # isort:skip # isort:skip +34 | import sys; import os + | ^^^^^^^^^^^^^^^^^^^^^^^^^ I001 | = help: Organize imports From 1593dbf9755148f9ba3f56818c6fa44177ea7e5c Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Wed, 8 Jan 2025 10:37:22 -0500 Subject: [PATCH 13/18] test: update another improperly rendered range This one almost looks like it fits into the other failure categories, but without identifying root causes, it's hard to say for sure. The span here does end after a line terminator, so it feels like it's like the rest. I also isolated this change since I found the snapshot diff pretty hard to read and wanted to look at it more closely. In this case, the before is: E204.py:31:2: E204 [*] Whitespace after decorator | 30 | # E204 31 | @ \ | __^ 32 | | foo | |_^ E204 33 | def baz(): 34 | print('baz') | = help: Remove whitespace And the after is: E204.py:31:2: E204 [*] Whitespace after decorator | 30 | # E204 31 | @ \ | ^^ E204 32 | foo 33 | def baz(): 34 | print('baz') | = help: Remove whitespace The updated rendering is clearly an improvement, since `foo` itself is not really the subject of the diagnostic. The whitespace is. Also, the new rendering matches the span fed to `annotate-snippets`, where as the old rendering does not. --- ...r__rules__pycodestyle__tests__E204_E204.py.snap | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E204_E204.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E204_E204.py.snap index 8e60ead61bdd0..2ef347934b097 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E204_E204.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E204_E204.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E204.py:14:2: E204 [*] Whitespace after decorator | @@ -44,13 +43,12 @@ E204.py:25:6: E204 [*] Whitespace after decorator E204.py:31:2: E204 [*] Whitespace after decorator | -30 | # E204 -31 | @ \ - | __^ -32 | | foo - | |_^ E204 -33 | def baz(): -34 | print('baz') +30 | # E204 +31 | @ \ + | ^^ E204 +32 | foo +33 | def baz(): +34 | print('baz') | = help: Remove whitespace From 8ce00fe1072f0aeb2ec1d7d38200872034dfec54 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Wed, 8 Jan 2025 11:41:20 -0500 Subject: [PATCH 14/18] ruff_annotate_snippets: update snapshot for single ASCII whitespace source The change to the rendering code is elaborated on in more detail here, where I attempted to upstream it: https://github.com/rust-lang/annotate-snippets-rs/pull/169 Otherwise, the snapshot diff also shows a bug fix: a `^` is now rendered where as it previously was not. --- crates/ruff_annotate_snippets/src/renderer/display_list.rs | 4 +--- .../ruff_linter__rules__pycodestyle__tests__w292_4.snap | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/crates/ruff_annotate_snippets/src/renderer/display_list.rs b/crates/ruff_annotate_snippets/src/renderer/display_list.rs index 95a1d69b1c110..bd723e7dd1ab0 100644 --- a/crates/ruff_annotate_snippets/src/renderer/display_list.rs +++ b/crates/ruff_annotate_snippets/src/renderer/display_list.rs @@ -1394,9 +1394,7 @@ fn format_body( } }) .sum(); - if line.chars().any(|c| !c.is_whitespace()) { - whitespace_margin = min(whitespace_margin, leading_whitespace); - } + whitespace_margin = min(whitespace_margin, leading_whitespace); max_line_len = max(max_line_len, line_length); let line_start_index = line_range.0; diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__w292_4.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__w292_4.snap index cadfcb66a8f56..31356cd79f95a 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__w292_4.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__w292_4.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- W292_4.py:1:2: W292 [*] No newline at end of file | 1 | - | W292 + | ^ W292 | = help: Add trailing newline From 6557d930b6729ef14ced52d99c87e288a56b679c Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Wed, 8 Jan 2025 12:54:31 -0500 Subject: [PATCH 15/18] ruff_annotate_snippets: fix false positive line trimming MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fix was sent upstream and the PR description includes more details: https://github.com/rust-lang/annotate-snippets-rs/pull/170 Without this fix, there was an errant snapshot diff that looked like this: | 1 | version = "0.1.0" 2 | # Ensure that the spans from toml handle utf-8 correctly 3 | authors = [ | ___________^ 4 | | { name = "Z͑ͫ̓ͪ̂ͫ̽͏̴̙...A̴̵̜̰͔ͫ͗͢L̠ͨͧͩ͘G̴̻͈͍̑͗̎̅͛́Ǫ̵̹̻̝̳͂̌̌͘", email = 1 } 5 | | ] | |_^ RUF200 | That ellipsis should _not_ be inserted since the line is not actually truncated. The handling of line length (in bytes versus actual rendered length) wasn't quite being handled correctly in all cases. With this fix, there's (correctly) no snapshot diff. --- .../src/renderer/display_list.rs | 33 +++++++++---------- .../src/renderer/margin.rs | 12 ------- 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/crates/ruff_annotate_snippets/src/renderer/display_list.rs b/crates/ruff_annotate_snippets/src/renderer/display_list.rs index bd723e7dd1ab0..f9c774c2fd6df 100644 --- a/crates/ruff_annotate_snippets/src/renderer/display_list.rs +++ b/crates/ruff_annotate_snippets/src/renderer/display_list.rs @@ -331,28 +331,27 @@ impl DisplaySet<'_> { // On long lines, we strip the source line, accounting for unicode. let mut taken = 0; - let code: String = text - .chars() - .skip(left) - .take_while(|ch| { - // Make sure that the trimming on the right will fall within the terminal width. - // FIXME: `unicode_width` sometimes disagrees with terminals on how wide a `char` - // is. For now, just accept that sometimes the code line will be longer than - // desired. - let next = unicode_width::UnicodeWidthChar::width(*ch).unwrap_or(1); - if taken + next > right - left { - return false; - } - taken += next; - true - }) - .collect(); + let mut was_cut_right = false; + let mut code = String::new(); + for ch in text.chars().skip(left) { + // Make sure that the trimming on the right will fall within the terminal width. + // FIXME: `unicode_width` sometimes disagrees with terminals on how wide a `char` + // is. For now, just accept that sometimes the code line will be longer than + // desired. + let next = unicode_width::UnicodeWidthChar::width(ch).unwrap_or(1); + if taken + next > right - left { + was_cut_right = true; + break; + } + taken += next; + code.push(ch); + } buffer.puts(line_offset, code_offset, &code, Style::new()); if self.margin.was_cut_left() { // We have stripped some code/whitespace from the beginning, make it clear. buffer.puts(line_offset, code_offset, "...", *lineno_color); } - if self.margin.was_cut_right(line_len) { + if was_cut_right { buffer.puts(line_offset, code_offset + taken - 3, "...", *lineno_color); } diff --git a/crates/ruff_annotate_snippets/src/renderer/margin.rs b/crates/ruff_annotate_snippets/src/renderer/margin.rs index c484416610782..59bd550745dcc 100644 --- a/crates/ruff_annotate_snippets/src/renderer/margin.rs +++ b/crates/ruff_annotate_snippets/src/renderer/margin.rs @@ -58,18 +58,6 @@ impl Margin { self.computed_left > 0 } - pub(crate) fn was_cut_right(&self, line_len: usize) -> bool { - let right = - if self.computed_right == self.span_right || self.computed_right == self.label_right { - // Account for the "..." padding given above. Otherwise we end up with code lines that - // do fit but end in "..." as if they were trimmed. - self.computed_right - ELLIPSIS_PASSING - } else { - self.computed_right - }; - right < line_len && self.computed_left + self.term_width < line_len - } - fn compute(&mut self, max_line_len: usize) { // When there's a lot of whitespace (>20), we want to trim it as it is useless. self.computed_left = if self.whitespace_left > LONG_WHITESPACE { From fbff35c506b39b4124172abfdd2d98327ca04e5f Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Thu, 9 Jan 2025 13:08:35 -0500 Subject: [PATCH 16/18] ruff_annotate_snippets: support overriding the "cut indicator" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We do this because `...` is valid Python, which makes it pretty likely that some line trimming will lead to ambiguous output. So we add support for overriding the cut indicator. This also requires changing some of the alignment math, which was previously tightly coupled to `...`. For Ruff, we go with `…` (`U+2026 HORIZONTAL ELLIPSIS`) for our cut indicator. For more details, see the patch sent to upstream: https://github.com/rust-lang/annotate-snippets-rs/pull/172 --- .../src/renderer/display_list.rs | 55 ++++++++++++++----- .../src/renderer/mod.rs | 12 ++++ .../ruff_annotate_snippets/tests/formatter.rs | 39 +++++++++++++ crates/ruff_linter/src/message/text.rs | 3 +- crates/ruff_python_parser/tests/fixtures.rs | 2 +- 5 files changed, 94 insertions(+), 17 deletions(-) diff --git a/crates/ruff_annotate_snippets/src/renderer/display_list.rs b/crates/ruff_annotate_snippets/src/renderer/display_list.rs index f9c774c2fd6df..95b0a98639682 100644 --- a/crates/ruff_annotate_snippets/src/renderer/display_list.rs +++ b/crates/ruff_annotate_snippets/src/renderer/display_list.rs @@ -38,6 +38,8 @@ use std::fmt::Display; use std::ops::Range; use std::{cmp, fmt}; +use unicode_width::UnicodeWidthStr; + use crate::renderer::styled_buffer::StyledBuffer; use crate::renderer::{stylesheet::Stylesheet, Margin, Style, DEFAULT_TERM_WIDTH}; @@ -53,6 +55,7 @@ pub(crate) struct DisplayList<'a> { pub(crate) body: Vec>, pub(crate) stylesheet: &'a Stylesheet, pub(crate) anonymized_line_numbers: bool, + pub(crate) cut_indicator: &'static str, } impl PartialEq for DisplayList<'_> { @@ -119,13 +122,21 @@ impl<'a> DisplayList<'a> { stylesheet: &'a Stylesheet, anonymized_line_numbers: bool, term_width: usize, + cut_indicator: &'static str, ) -> DisplayList<'a> { - let body = format_message(message, term_width, anonymized_line_numbers, true); + let body = format_message( + message, + term_width, + anonymized_line_numbers, + cut_indicator, + true, + ); Self { body, stylesheet, anonymized_line_numbers, + cut_indicator, } } @@ -143,6 +154,7 @@ impl<'a> DisplayList<'a> { multiline_depth, self.stylesheet, self.anonymized_line_numbers, + self.cut_indicator, buffer, )?; } @@ -270,6 +282,7 @@ impl DisplaySet<'_> { } // Adapted from https://github.com/rust-lang/rust/blob/d371d17496f2ce3a56da76aa083f4ef157572c20/compiler/rustc_errors/src/emitter.rs#L706-L1211 + #[allow(clippy::too_many_arguments)] #[inline] fn format_line( &self, @@ -278,6 +291,7 @@ impl DisplaySet<'_> { multiline_depth: usize, stylesheet: &Stylesheet, anonymized_line_numbers: bool, + cut_indicator: &'static str, buffer: &mut StyledBuffer, ) -> fmt::Result { let line_offset = buffer.num_lines(); @@ -349,10 +363,15 @@ impl DisplaySet<'_> { buffer.puts(line_offset, code_offset, &code, Style::new()); if self.margin.was_cut_left() { // We have stripped some code/whitespace from the beginning, make it clear. - buffer.puts(line_offset, code_offset, "...", *lineno_color); + buffer.puts(line_offset, code_offset, cut_indicator, *lineno_color); } if was_cut_right { - buffer.puts(line_offset, code_offset + taken - 3, "...", *lineno_color); + buffer.puts( + line_offset, + code_offset + taken - cut_indicator.width(), + cut_indicator, + *lineno_color, + ); } let left: usize = text @@ -724,7 +743,7 @@ impl DisplaySet<'_> { Ok(()) } DisplayLine::Fold { inline_marks } => { - buffer.puts(line_offset, 0, "...", *stylesheet.line_no()); + buffer.puts(line_offset, 0, cut_indicator, *stylesheet.line_no()); if !inline_marks.is_empty() || 0 < multiline_depth { format_inline_marks( line_offset, @@ -987,12 +1006,13 @@ impl<'a> Iterator for CursorLines<'a> { } } -fn format_message( - message: snippet::Message<'_>, +fn format_message<'m>( + message: snippet::Message<'m>, term_width: usize, anonymized_line_numbers: bool, + cut_indicator: &'static str, primary: bool, -) -> Vec> { +) -> Vec> { let snippet::Message { level, id, @@ -1016,6 +1036,7 @@ fn format_message( !footer.is_empty(), term_width, anonymized_line_numbers, + cut_indicator, )); } @@ -1035,6 +1056,7 @@ fn format_message( annotation, term_width, anonymized_line_numbers, + cut_indicator, false, )); } @@ -1089,13 +1111,14 @@ fn format_label( result } -fn format_snippet( - snippet: snippet::Snippet<'_>, +fn format_snippet<'m>( + snippet: snippet::Snippet<'m>, is_first: bool, has_footer: bool, term_width: usize, anonymized_line_numbers: bool, -) -> DisplaySet<'_> { + cut_indicator: &'static str, +) -> DisplaySet<'m> { let main_range = snippet.annotations.first().map(|x| x.range.start); let origin = snippet.origin; let need_empty_header = origin.is_some() || is_first; @@ -1105,6 +1128,7 @@ fn format_snippet( has_footer, term_width, anonymized_line_numbers, + cut_indicator, ); let header = format_header(origin, main_range, &body.display_lines, is_first); @@ -1241,7 +1265,7 @@ fn fold_body(body: Vec>) -> Vec> { match unhighlighed_lines.len() { 0 => {} n if n <= INNER_UNFOLD_SIZE => { - // Rather than render `...`, don't fold + // Rather than render our cut indicator, don't fold lines.append(&mut unhighlighed_lines); } _ => { @@ -1280,13 +1304,14 @@ fn fold_body(body: Vec>) -> Vec> { lines } -fn format_body( - snippet: snippet::Snippet<'_>, +fn format_body<'m>( + snippet: snippet::Snippet<'m>, need_empty_header: bool, has_footer: bool, term_width: usize, anonymized_line_numbers: bool, -) -> DisplaySet<'_> { + cut_indicator: &'static str, +) -> DisplaySet<'m> { let source_len = snippet.source.len(); if let Some(bigger) = snippet.annotations.iter().find_map(|x| { // Allow highlighting one past the last character in the source. @@ -1617,7 +1642,7 @@ fn format_body( current_line.to_string().len() }; - let width_offset = 3 + max_line_num_len; + let width_offset = cut_indicator.len() + max_line_num_len; if span_left_margin == usize::MAX { span_left_margin = 0; diff --git a/crates/ruff_annotate_snippets/src/renderer/mod.rs b/crates/ruff_annotate_snippets/src/renderer/mod.rs index 52ec9ad331e9a..177ffb9ab1a28 100644 --- a/crates/ruff_annotate_snippets/src/renderer/mod.rs +++ b/crates/ruff_annotate_snippets/src/renderer/mod.rs @@ -9,6 +9,7 @@ //! //! let renderer = Renderer::styled(); //! println!("{}", renderer.render(snippet)); +//! ``` mod display_list; mod margin; @@ -30,6 +31,7 @@ pub struct Renderer { anonymized_line_numbers: bool, term_width: usize, stylesheet: Stylesheet, + cut_indicator: &'static str, } impl Renderer { @@ -39,6 +41,7 @@ impl Renderer { anonymized_line_numbers: false, term_width: DEFAULT_TERM_WIDTH, stylesheet: Stylesheet::plain(), + cut_indicator: "...", } } @@ -151,6 +154,14 @@ impl Renderer { self } + /// Set the string used for when a long line is cut. + /// + /// The default is `...` (three `U+002E` characters). + pub const fn cut_indicator(mut self, string: &'static str) -> Self { + self.cut_indicator = string; + self + } + /// Render a snippet into a `Display`able object pub fn render<'a>(&'a self, msg: Message<'a>) -> impl Display + 'a { DisplayList::new( @@ -158,6 +169,7 @@ impl Renderer { &self.stylesheet, self.anonymized_line_numbers, self.term_width, + self.cut_indicator, ) } } diff --git a/crates/ruff_annotate_snippets/tests/formatter.rs b/crates/ruff_annotate_snippets/tests/formatter.rs index e66ad115475fb..c150aa54386a8 100644 --- a/crates/ruff_annotate_snippets/tests/formatter.rs +++ b/crates/ruff_annotate_snippets/tests/formatter.rs @@ -990,3 +990,42 @@ error: title let renderer = Renderer::plain(); assert_data_eq!(renderer.render(input).to_string(), expected); } + +#[test] +fn long_line_cut() { + let source = "abcd abcd abcd abcd abcd abcd abcd"; + let input = Level::Error.title("").snippet( + Snippet::source(source) + .line_start(1) + .annotation(Level::Error.span(0..4)), + ); + let expected = str![[r#" +error + | +1 | abcd abcd a... + | ^^^^ + | +"#]]; + let renderer = Renderer::plain().term_width(18); + assert_data_eq!(renderer.render(input).to_string(), expected); +} + +#[test] +fn long_line_cut_custom() { + let source = "abcd abcd abcd abcd abcd abcd abcd"; + let input = Level::Error.title("").snippet( + Snippet::source(source) + .line_start(1) + .annotation(Level::Error.span(0..4)), + ); + // This trims a little less because `…` is visually smaller than `...`. + let expected = str![[r#" +error + | +1 | abcd abcd abc… + | ^^^^ + | +"#]]; + let renderer = Renderer::plain().term_width(18).cut_indicator("…"); + assert_data_eq!(renderer.render(input).to_string(), expected); +} diff --git a/crates/ruff_linter/src/message/text.rs b/crates/ruff_linter/src/message/text.rs index 24e0787aa35ba..86499539a060a 100644 --- a/crates/ruff_linter/src/message/text.rs +++ b/crates/ruff_linter/src/message/text.rs @@ -277,7 +277,8 @@ impl Display for MessageCodeFrame<'_> { Renderer::styled() } else { Renderer::plain() - }; + } + .cut_indicator("…"); let rendered = renderer.render(message); writeln!(f, "{rendered}") } diff --git a/crates/ruff_python_parser/tests/fixtures.rs b/crates/ruff_python_parser/tests/fixtures.rs index e8516b6a648f9..debe45415a461 100644 --- a/crates/ruff_python_parser/tests/fixtures.rs +++ b/crates/ruff_python_parser/tests/fixtures.rs @@ -210,7 +210,7 @@ impl std::fmt::Display for CodeFrame<'_> { .annotation(annotation) .fold(false); let message = Level::None.title("").snippet(snippet); - let renderer = Renderer::plain(); + let renderer = Renderer::plain().cut_indicator("…"); let rendered = renderer.render(message); writeln!(f, "{rendered}") } From 1db1c70c3dd8c29103a05d391fa8f9cef652cf17 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Wed, 8 Jan 2025 12:59:53 -0500 Subject: [PATCH 17/18] test: update snapshots with trimmed lines This updates snapshots where long lines now get trimmed with `annotate-snippets`. And an ellipsis is inserted to indicate trimming. This is a little hokey to test since in tests we don't do any styling. And I believe this just uses the default "max term width" for rendering. But in real life, it seems like a big improvement to have long lines trimmed if they would otherwise wrap in the terminal. So this seems like an improvement to me. There are some other fixes here that overlap with previous categories. --- ..._flake8_pyi__tests__PYI003_PYI003.pyi.snap | 7 +- ..._flake8_pyi__tests__PYI033_PYI033.pyi.snap | 81 ++++--- ...__flake8_pyi__tests__PYI034_PYI034.py.snap | 38 ++-- ..._flake8_pyi__tests__PYI034_PYI034.pyi.snap | 22 +- ...__flake8_pyi__tests__PYI036_PYI036.py.snap | 53 +++-- ..._flake8_pyi__tests__PYI036_PYI036.pyi.snap | 55 +++-- ..._flake8_pyi__tests__PYI052_PYI052.pyi.snap | 7 +- ..._flake8_pyi__tests__PYI066_PYI066.pyi.snap | 22 +- ...ing-only-third-party-import_quote3.py.snap | 26 +-- ...ules__pycodestyle__tests__E231_E23.py.snap | 29 ++- ...les__pycodestyle__tests__E501_E501.py.snap | 13 +- ...__pycodestyle__tests__task_tags_false.snap | 85 ++++---- ...les__pyflakes__tests__F821_F821_17.py.snap | 55 +++-- ...ylint__tests__max_boolean_expressions.snap | 9 +- ...__rules__pyupgrade__tests__UP031_0.py.snap | 200 +++++++++--------- 15 files changed, 343 insertions(+), 359 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI003_PYI003.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI003_PYI003.pyi.snap index 154f4567e89e7..99096e74e8d98 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI003_PYI003.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI003_PYI003.pyi.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI003.pyi:4:4: PYI003 Unrecognized `sys.version_info` check | 3 | if sys.version_info[0] == 2: ... -4 | if sys.version_info[0] == True: ... # Y003 Unrecognized sys.version_info check # E712 comparison to True should be 'if cond is True:' or 'if cond:' +4 | if sys.version_info[0] == True: ... # Y003 Unrecognized sys.version_info check # E712 comparison to True should be 'if cond is True:'… | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 5 | if sys.version_info[0.0] == 2: ... # Y003 Unrecognized sys.version_info check 6 | if sys.version_info[False] == 2: ... # Y003 Unrecognized sys.version_info check @@ -14,7 +13,7 @@ PYI003.pyi:4:4: PYI003 Unrecognized `sys.version_info` check PYI003.pyi:5:4: PYI003 Unrecognized `sys.version_info` check | 3 | if sys.version_info[0] == 2: ... -4 | if sys.version_info[0] == True: ... # Y003 Unrecognized sys.version_info check # E712 comparison to True should be 'if cond is True:' or 'if cond:' +4 | if sys.version_info[0] == True: ... # Y003 Unrecognized sys.version_info check # E712 comparison to True should be 'if cond is True:'… 5 | if sys.version_info[0.0] == 2: ... # Y003 Unrecognized sys.version_info check | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 6 | if sys.version_info[False] == 2: ... # Y003 Unrecognized sys.version_info check @@ -23,7 +22,7 @@ PYI003.pyi:5:4: PYI003 Unrecognized `sys.version_info` check PYI003.pyi:6:4: PYI003 Unrecognized `sys.version_info` check | -4 | if sys.version_info[0] == True: ... # Y003 Unrecognized sys.version_info check # E712 comparison to True should be 'if cond is True:' or 'if cond:' +4 | if sys.version_info[0] == True: ... # Y003 Unrecognized sys.version_info check # E712 comparison to True should be 'if cond is True:'… 5 | if sys.version_info[0.0] == 2: ... # Y003 Unrecognized sys.version_info check 6 | if sys.version_info[False] == 2: ... # Y003 Unrecognized sys.version_info check | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI033_PYI033.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI033_PYI033.pyi.snap index e8b1546f725cb..1908a7ab920e5 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI033_PYI033.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI033_PYI033.pyi.snap @@ -1,44 +1,43 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI033.pyi:6:22: PYI033 Don't use type comments in stub file | -4 | from typing import TypeAlias -5 | -6 | A: TypeAlias = None # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 -7 | B: TypeAlias = None # type: str # And here's an extra comment about why it's that type # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") -8 | C: TypeAlias = None #type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") +4 | … import TypeAlias +5 | … +6 | …s = None # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 +7 | …s = None # type: str # And here's an extra comment about why it's that type # Y033 Do not use type comments in stubs (e.g. use "x: … +8 | …s = None #type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") | PYI033.pyi:7:22: PYI033 Don't use type comments in stub file | -6 | A: TypeAlias = None # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") -7 | B: TypeAlias = None # type: str # And here's an extra comment about why it's that type # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 -8 | C: TypeAlias = None #type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") -9 | D: TypeAlias = None # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") +6 | …one # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") +7 | …one # type: str # And here's an extra comment about why it's that type # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 +8 | …one #type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") +9 | …one # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") | PYI033.pyi:8:22: PYI033 Don't use type comments in stub file | - 6 | A: TypeAlias = None # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - 7 | B: TypeAlias = None # type: str # And here's an extra comment about why it's that type # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - 8 | C: TypeAlias = None #type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 - 9 | D: TypeAlias = None # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") -10 | E: TypeAlias = None# type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") + 6 | …s = None # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") + 7 | …s = None # type: str # And here's an extra comment about why it's that type # Y033 Do not use type comments in stubs (e.g. use "x:… + 8 | …s = None #type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 + 9 | …s = None # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") +10 | …s = None# type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") | PYI033.pyi:9:22: PYI033 Don't use type comments in stub file | - 7 | B: TypeAlias = None # type: str # And here's an extra comment about why it's that type # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - 8 | C: TypeAlias = None #type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - 9 | D: TypeAlias = None # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 -10 | E: TypeAlias = None# type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") -11 | F: TypeAlias = None#type:int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") + 7 | … None # type: str # And here's an extra comment about why it's that type # Y033 Do not use type comments in stubs (e.g. use "x: in… + 8 | … None #type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") + 9 | … None # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 +10 | … None# type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") +11 | … None#type:int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") | PYI033.pyi:10:20: PYI033 Don't use type comments in stub file @@ -56,35 +55,35 @@ PYI033.pyi:11:20: PYI033 Don't use type comments in stub file 10 | E: TypeAlias = None# type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") 11 | F: TypeAlias = None#type:int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 -12 | +12 | 13 | def func( | PYI033.pyi:14:12: PYI033 Don't use type comments in stub file | -13 | def func( -14 | arg1, # type: dict[str, int] # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 -15 | arg2 # type: Sequence[bytes] # And here's some more info about this arg # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") -16 | ): ... +13 | …func( +14 | …arg1, # type: dict[str, int] # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 +15 | …arg2 # type: Sequence[bytes] # And here's some more info about this arg # Y033 Do not use type comments in stubs (e.g. use "x: int… +16 | ….. | PYI033.pyi:15:11: PYI033 Don't use type comments in stub file | -13 | def func( -14 | arg1, # type: dict[str, int] # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") -15 | arg2 # type: Sequence[bytes] # And here's some more info about this arg # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 -16 | ): ... +13 | …unc( +14 | …rg1, # type: dict[str, int] # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") +15 | …rg2 # type: Sequence[bytes] # And here's some more info about this arg # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 +16 | …. | PYI033.pyi:19:29: PYI033 Don't use type comments in stub file | -18 | class Foo: -19 | Attr: TypeAlias = None # type: set[str] # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 -20 | -21 | G: TypeAlias = None # type: ignore +18 | … +19 | … None # type: set[str] # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 +20 | … +21 | …# type: ignore | PYI033.pyi:29:22: PYI033 Don't use type comments in stub file @@ -92,7 +91,7 @@ PYI033.pyi:29:22: PYI033 Don't use type comments in stub file 28 | # Whole line commented out # type: int 29 | M: TypeAlias = None # type: can't parse me! | ^^^^^^^^^^^^^^^^^^^^^^^ PYI033 -30 | +30 | 31 | class Bar: | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.py.snap index d2b3356ff6077..bb520776d6b94 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.py.snap @@ -7,7 +7,7 @@ PYI034.py:21:9: PYI034 [*] `__new__` methods in classes like `Bad` usually retur 20 | ): # Y040 Do not inherit from "object" explicitly, as it is redundant in Python 3 21 | def __new__(cls, *args: Any, **kwargs: Any) -> Bad: | ^^^^^^^ PYI034 -22 | ... # Y034 "__new__" methods usually return "self" at runtime. Consider using "typing_extensions.Self" in "Bad.__new__", e.g. "def __new__(cls, *args: Any, **kwargs: Any) -> Self: ..." +22 | ... # Y034 "__new__" methods usually return "self" at runtime. Consider using "typing_extensions.Self" in "Bad.__new__", e.g.… | = help: Use `Self` as return type @@ -24,10 +24,10 @@ PYI034.py:21:9: PYI034 [*] `__new__` methods in classes like `Bad` usually retur PYI034.py:36:9: PYI034 [*] `__enter__` methods in classes like `Bad` usually return `self` at runtime | 34 | ... # Y032 Prefer "object" to "Any" for the second parameter in "__ne__" methods -35 | +35 | 36 | def __enter__(self) -> Bad: | ^^^^^^^^^ PYI034 -37 | ... # Y034 "__enter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Self" in "Bad.__enter__", e.g. "def __enter__(self) -> Self: ..." +37 | ... # Y034 "__enter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Self… | = help: Use `Self` as return type @@ -43,11 +43,11 @@ PYI034.py:36:9: PYI034 [*] `__enter__` methods in classes like `Bad` usually ret PYI034.py:39:15: PYI034 [*] `__aenter__` methods in classes like `Bad` usually return `self` at runtime | -37 | ... # Y034 "__enter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Self" in "Bad.__enter__", e.g. "def __enter__(self) -> Self: ..." -38 | +37 | ... # Y034 "__enter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Self… +38 | 39 | async def __aenter__(self) -> Bad: | ^^^^^^^^^^ PYI034 -40 | ... # Y034 "__aenter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Self" in "Bad.__aenter__", e.g. "async def __aenter__(self) -> Self: ..." +40 | ... # Y034 "__aenter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Sel… | = help: Use `Self` as return type @@ -63,11 +63,11 @@ PYI034.py:39:15: PYI034 [*] `__aenter__` methods in classes like `Bad` usually r PYI034.py:42:9: PYI034 [*] `__iadd__` methods in classes like `Bad` usually return `self` at runtime | -40 | ... # Y034 "__aenter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Self" in "Bad.__aenter__", e.g. "async def __aenter__(self) -> Self: ..." -41 | +40 | ... # Y034 "__aenter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Sel… +41 | 42 | def __iadd__(self, other: Bad) -> Bad: | ^^^^^^^^ PYI034 -43 | ... # Y034 "__iadd__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Self" in "Bad.__iadd__", e.g. "def __iadd__(self, other: Bad) -> Self: ..." +43 | ... # Y034 "__iadd__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Self"… | = help: Use `Self` as return type @@ -86,7 +86,7 @@ PYI034.py:165:9: PYI034 [*] `__iter__` methods in classes like `BadIterator1` us 164 | class BadIterator1(Iterator[int]): 165 | def __iter__(self) -> Iterator[int]: | ^^^^^^^^ PYI034 -166 | ... # Y034 "__iter__" methods in classes like "BadIterator1" usually return "self" at runtime. Consider using "typing_extensions.Self" in "BadIterator1.__iter__", e.g. "def __iter__(self) -> Self: ..." +166 | ... # Y034 "__iter__" methods in classes like "BadIterator1" usually return "self" at runtime. Consider using "typing_extens… | = help: Use `Self` as return type @@ -106,7 +106,7 @@ PYI034.py:172:9: PYI034 [*] `__iter__` methods in classes like `BadIterator2` us 171 | ): # Y022 Use "collections.abc.Iterator[T]" instead of "typing.Iterator[T]" (PEP 585 syntax) 172 | def __iter__(self) -> Iterator[int]: | ^^^^^^^^ PYI034 -173 | ... # Y034 "__iter__" methods in classes like "BadIterator2" usually return "self" at runtime. Consider using "typing_extensions.Self" in "BadIterator2.__iter__", e.g. "def __iter__(self) -> Self: ..." +173 | ... # Y034 "__iter__" methods in classes like "BadIterator2" usually return "self" at runtime. Consider using "typing_extens… | = help: Use `Self` as return type @@ -126,7 +126,7 @@ PYI034.py:179:9: PYI034 [*] `__iter__` methods in classes like `BadIterator3` us 178 | ): # Y022 Use "collections.abc.Iterator[T]" instead of "typing.Iterator[T]" (PEP 585 syntax) 179 | def __iter__(self) -> collections.abc.Iterator[int]: | ^^^^^^^^ PYI034 -180 | ... # Y034 "__iter__" methods in classes like "BadIterator3" usually return "self" at runtime. Consider using "typing_extensions.Self" in "BadIterator3.__iter__", e.g. "def __iter__(self) -> Self: ..." +180 | ... # Y034 "__iter__" methods in classes like "BadIterator3" usually return "self" at runtime. Consider using "typing_extens… | = help: Use `Self` as return type @@ -146,7 +146,7 @@ PYI034.py:185:9: PYI034 [*] `__iter__` methods in classes like `BadIterator4` us 184 | # Note: *Iterable*, not *Iterator*, returned! 185 | def __iter__(self) -> Iterable[int]: | ^^^^^^^^ PYI034 -186 | ... # Y034 "__iter__" methods in classes like "BadIterator4" usually return "self" at runtime. Consider using "typing_extensions.Self" in "BadIterator4.__iter__", e.g. "def __iter__(self) -> Self: ..." +186 | ... # Y034 "__iter__" methods in classes like "BadIterator4" usually return "self" at runtime. Consider using "typing_extens… | = help: Use `Self` as return type @@ -165,7 +165,7 @@ PYI034.py:195:9: PYI034 [*] `__aiter__` methods in classes like `BadAsyncIterato 194 | class BadAsyncIterator(collections.abc.AsyncIterator[str]): 195 | def __aiter__(self) -> typing.AsyncIterator[str]: | ^^^^^^^^^ PYI034 -196 | ... # Y034 "__aiter__" methods in classes like "BadAsyncIterator" usually return "self" at runtime. Consider using "typing_extensions.Self" in "BadAsyncIterator.__aiter__", e.g. "def __aiter__(self) -> Self: ..." # Y022 Use "collections.abc.AsyncIterator[T]" instead of "typing.AsyncIterator[T]" (PEP 585 syntax) +196 | ... # Y034 "__aiter__" methods in classes like "BadAsyncIterator" usually return "self" at runtime. Consider using "typing_e… | = help: Use `Self` as return type @@ -242,7 +242,7 @@ PYI034.py:328:9: PYI034 [*] `__enter__` methods in classes like `NonGeneric1` us 327 | def __new__(cls: type[NonGeneric1], *args, **kwargs) -> NonGeneric1: ... 328 | def __enter__(self: NonGeneric1) -> NonGeneric1: ... | ^^^^^^^^^ PYI034 -329 | +329 | 330 | class NonGeneric2(tuple): | = help: Use `Self` as return type @@ -262,7 +262,7 @@ PYI034.py:331:9: PYI034 [*] `__new__` methods in classes like `NonGeneric2` usua 330 | class NonGeneric2(tuple): 331 | def __new__(cls: Type[NonGeneric2]) -> NonGeneric2: ... | ^^^^^^^ PYI034 -332 | +332 | 333 | class Generic1[T](list): | = help: Use `Self` as return type @@ -340,7 +340,7 @@ PYI034.py:346:9: PYI034 `__enter__` methods in classes like `Generic2` usually r 345 | def __new__(cls: type[Generic2]) -> Generic2: ... 346 | def __enter__(self: Generic2) -> Generic2: ... | ^^^^^^^^^ PYI034 -347 | +347 | 348 | class Generic3(tuple[*Ts]): | = help: Use `Self` as return type @@ -380,7 +380,7 @@ PYI034.py:350:9: PYI034 `__enter__` methods in classes like `Generic3` usually r 349 | def __new__(cls: type[Generic3]) -> Generic3: ... 350 | def __enter__(self: Generic3) -> Generic3: ... | ^^^^^^^^^ PYI034 -351 | +351 | 352 | class Generic4(collections.abc.Callable[P, ...]): | = help: Use `Self` as return type @@ -420,7 +420,7 @@ PYI034.py:354:9: PYI034 `__enter__` methods in classes like `Generic4` usually r 353 | def __new__(cls: type[Generic4]) -> Generic4: ... 354 | def __enter__(self: Generic4) -> Generic4: ... | ^^^^^^^^^ PYI034 -355 | +355 | 356 | from some_module import PotentialTypeVar | = help: Use `Self` as return type diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.pyi.snap index 941c11fe99173..49952c3ef7584 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.pyi.snap @@ -8,7 +8,7 @@ PYI034.pyi:20:9: PYI034 [*] `__new__` methods in classes like `Bad` usually retu 20 | def __new__( | ^^^^^^^ PYI034 21 | cls, *args: Any, **kwargs: Any -22 | ) -> Bad: ... # Y034 "__new__" methods usually return "self" at runtime. Consider using "typing_extensions.Self" in "Bad.__new__", e.g. "def __new__(cls, *args: Any, **kwargs: Any) -> Self: ..." +22 | ) -> Bad: ... # Y034 "__new__" methods usually return "self" at runtime. Consider using "typing_extensions.Self" in "Bad.__new__"… | = help: Use `Self` as return type @@ -29,7 +29,7 @@ PYI034.pyi:35:9: PYI034 [*] `__enter__` methods in classes like `Bad` usually re 35 | def __enter__( | ^^^^^^^^^ PYI034 36 | self, -37 | ) -> Bad: ... # Y034 "__enter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Self" in "Bad.__enter__", e.g. "def __enter__(self) -> Self: ..." +37 | ) -> Bad: ... # Y034 "__enter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extension… | = help: Use `Self` as return type @@ -46,11 +46,11 @@ PYI034.pyi:35:9: PYI034 [*] `__enter__` methods in classes like `Bad` usually re PYI034.pyi:38:15: PYI034 [*] `__aenter__` methods in classes like `Bad` usually return `self` at runtime | 36 | self, -37 | ) -> Bad: ... # Y034 "__enter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Self" in "Bad.__enter__", e.g. "def __enter__(self) -> Self: ..." +37 | ) -> Bad: ... # Y034 "__enter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extension… 38 | async def __aenter__( | ^^^^^^^^^^ PYI034 39 | self, -40 | ) -> Bad: ... # Y034 "__aenter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Self" in "Bad.__aenter__", e.g. "async def __aenter__(self) -> Self: ..." +40 | ) -> Bad: ... # Y034 "__aenter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensio… | = help: Use `Self` as return type @@ -67,11 +67,11 @@ PYI034.pyi:38:15: PYI034 [*] `__aenter__` methods in classes like `Bad` usually PYI034.pyi:41:9: PYI034 [*] `__iadd__` methods in classes like `Bad` usually return `self` at runtime | 39 | self, -40 | ) -> Bad: ... # Y034 "__aenter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Self" in "Bad.__aenter__", e.g. "async def __aenter__(self) -> Self: ..." +40 | ) -> Bad: ... # Y034 "__aenter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensio… 41 | def __iadd__( | ^^^^^^^^ PYI034 42 | self, other: Bad -43 | ) -> Bad: ... # Y034 "__iadd__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Self" in "Bad.__iadd__", e.g. "def __iadd__(self, other: Bad) -> Self: ..." +43 | ) -> Bad: ... # Y034 "__iadd__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions… | = help: Use `Self` as return type @@ -223,7 +223,7 @@ PYI034.pyi:222:9: PYI034 [*] `__enter__` methods in classes like `NonGeneric1` u 221 | def __new__(cls: type[NonGeneric1], *args, **kwargs) -> NonGeneric1: ... 222 | def __enter__(self: NonGeneric1) -> NonGeneric1: ... | ^^^^^^^^^ PYI034 -223 | +223 | 224 | class NonGeneric2(tuple): | = help: Use `Self` as return type @@ -243,7 +243,7 @@ PYI034.pyi:225:9: PYI034 [*] `__new__` methods in classes like `NonGeneric2` usu 224 | class NonGeneric2(tuple): 225 | def __new__(cls: Type[NonGeneric2]) -> NonGeneric2: ... | ^^^^^^^ PYI034 -226 | +226 | 227 | class Generic1[T](list): | = help: Use `Self` as return type @@ -321,7 +321,7 @@ PYI034.pyi:240:9: PYI034 `__enter__` methods in classes like `Generic2` usually 239 | def __new__(cls: type[Generic2]) -> Generic2: ... 240 | def __enter__(self: Generic2) -> Generic2: ... | ^^^^^^^^^ PYI034 -241 | +241 | 242 | class Generic3(tuple[*Ts]): | = help: Use `Self` as return type @@ -361,7 +361,7 @@ PYI034.pyi:244:9: PYI034 `__enter__` methods in classes like `Generic3` usually 243 | def __new__(cls: type[Generic3]) -> Generic3: ... 244 | def __enter__(self: Generic3) -> Generic3: ... | ^^^^^^^^^ PYI034 -245 | +245 | 246 | class Generic4(collections.abc.Callable[P, ...]): | = help: Use `Self` as return type @@ -401,7 +401,7 @@ PYI034.pyi:248:9: PYI034 `__enter__` methods in classes like `Generic4` usually 247 | def __new__(cls: type[Generic4]) -> Generic4: ... 248 | def __enter__(self: Generic4) -> Generic4: ... | ^^^^^^^^^ PYI034 -249 | +249 | 250 | from some_module import PotentialTypeVar | = help: Use `Self` as return type diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.py.snap index 38fe8de87fab5..34e31a8ea7aa3 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI036.py:54:31: PYI036 [*] Star-args in `__exit__` should be annotated with `object` | @@ -27,7 +26,7 @@ PYI036.py:55:24: PYI036 If there are no star-args, `__aexit__` should have at le 54 | def __exit__(self, *args: Any) -> None: ... # PYI036: Bad star-args annotation 55 | async def __aexit__(self) -> None: ... # PYI036: Missing args | ^^^^^^ PYI036 -56 | +56 | 57 | class BadTwo: | @@ -45,54 +44,54 @@ PYI036.py:59:48: PYI036 All keyword-only arguments in `__aexit__` must have a de 58 | def __exit__(self, typ, exc, tb, weird_extra_arg) -> None: ... # PYI036: Extra arg must have default 59 | async def __aexit__(self, typ, exc, tb, *, weird_extra_arg) -> None: ...# PYI036: Extra arg must have default | ^^^^^^^^^^^^^^^ PYI036 -60 | +60 | 61 | class BadThree: | PYI036.py:62:29: PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None` | 61 | class BadThree: -62 | def __exit__(self, typ: type[BaseException], exc: BaseException | None, tb: TracebackType | None) -> None: ... # PYI036: First arg has bad annotation +62 | def __exit__(self, typ: type[BaseException], exc: BaseException | None, tb: TracebackType | None) -> None: ... # PYI036: First arg… | ^^^^^^^^^^^^^^^^^^^ PYI036 -63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI036: Second arg has bad annotation +63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI0… | PYI036.py:63:73: PYI036 The second argument in `__aexit__` should be annotated with `object` or `BaseException | None` | 61 | class BadThree: -62 | def __exit__(self, typ: type[BaseException], exc: BaseException | None, tb: TracebackType | None) -> None: ... # PYI036: First arg has bad annotation -63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI036: Second arg has bad annotation +62 | def __exit__(self, typ: type[BaseException], exc: BaseException | None, tb: TracebackType | None) -> None: ... # PYI036: First arg… +63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI0… | ^^^^^^^^^^^^^ PYI036 -64 | +64 | 65 | class BadFour: | PYI036.py:63:94: PYI036 The third argument in `__aexit__` should be annotated with `object` or `types.TracebackType | None` | 61 | class BadThree: -62 | def __exit__(self, typ: type[BaseException], exc: BaseException | None, tb: TracebackType | None) -> None: ... # PYI036: First arg has bad annotation -63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI036: Second arg has bad annotation +62 | def __exit__(self, typ: type[BaseException], exc: BaseException | None, tb: TracebackType | None) -> None: ... # PYI036: First arg… +63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI0… | ^^^^^^^^^^^^^ PYI036 -64 | +64 | 65 | class BadFour: | PYI036.py:66:111: PYI036 The third argument in `__exit__` should be annotated with `object` or `types.TracebackType | None` | -65 | class BadFour: -66 | def __exit__(self, typ: typing.Optional[type[BaseException]], exc: typing.Union[BaseException, None], tb: TracebackType) -> None: ... # PYI036: Third arg has bad annotation - | ^^^^^^^^^^^^^ PYI036 -67 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, int]) -> bool | None: ... # PYI036: Third arg has bad annotation +65 | … +66 | …xception]], exc: typing.Union[BaseException, None], tb: TracebackType) -> None: ... # PYI036: Third arg has bad annotation + | ^^^^^^^^^^^^^ PYI036 +67 | …n] | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, int]) -> bool | None: ... # PYI036: Third arg has bad… | PYI036.py:67:101: PYI036 The third argument in `__aexit__` should be annotated with `object` or `types.TracebackType | None` | -65 | class BadFour: -66 | def __exit__(self, typ: typing.Optional[type[BaseException]], exc: typing.Union[BaseException, None], tb: TracebackType) -> None: ... # PYI036: Third arg has bad annotation -67 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, int]) -> bool | None: ... # PYI036: Third arg has bad annotation - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI036 -68 | -69 | class BadFive: +65 | … +66 | …eption]], exc: typing.Union[BaseException, None], tb: TracebackType) -> None: ... # PYI036: Third arg has bad annotation +67 | … | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, int]) -> bool | None: ... # PYI036: Third arg has bad a… + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI036 +68 | … +69 | … | PYI036.py:70:29: PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None` @@ -100,7 +99,7 @@ PYI036.py:70:29: PYI036 The first argument in `__exit__` should be annotated wit 69 | class BadFive: 70 | def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation | ^^^^^^^^^^^^^^^^^^^^ PYI036 -71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotation +71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotati… | PYI036.py:70:58: PYI036 [*] Star-args in `__exit__` should be annotated with `object` @@ -108,7 +107,7 @@ PYI036.py:70:58: PYI036 [*] Star-args in `__exit__` should be annotated with `ob 69 | class BadFive: 70 | def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation | ^^^^^^^^^ PYI036 -71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotation +71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotati… | = help: Annotate star-args with `object` @@ -126,9 +125,9 @@ PYI036.py:71:74: PYI036 [*] Star-args in `__aexit__` should be annotated with `o | 69 | class BadFive: 70 | def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation -71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotation +71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotati… | ^^^ PYI036 -72 | +72 | 73 | class BadSix: | = help: Annotate star-args with `object` @@ -157,7 +156,7 @@ PYI036.py:75:48: PYI036 All keyword-only arguments in `__aexit__` must have a de 74 | def __exit__(self, typ, exc, tb, weird_extra_arg, extra_arg2 = None) -> None: ... # PYI036: Extra arg must have default 75 | async def __aexit__(self, typ, exc, tb, *, weird_extra_arg) -> None: ... # PYI036: kwargs must have default | ^^^^^^^^^^^^^^^ PYI036 -76 | +76 | 77 | class AllPositionalOnlyArgs: | @@ -175,7 +174,7 @@ PYI036.py:83:95: PYI036 The third argument in `__aexit__` should be annotated wi 82 | def __exit__(self, typ: type[Exception] | None, exc: BaseException | None, tb: TracebackType | None, /) -> None: ... 83 | async def __aexit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: TracebackType, /) -> None: ... | ^^^^^^^^^^^^^ PYI036 -84 | +84 | 85 | # Definitions not in a class scope can do whatever, we don't care | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.pyi.snap index 84b458353f4e2..116a7f499e80d 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.pyi.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI036.pyi:54:31: PYI036 [*] Star-args in `__exit__` should be annotated with `object` | @@ -27,7 +26,7 @@ PYI036.pyi:55:24: PYI036 If there are no star-args, `__aexit__` should have at l 54 | def __exit__(self, *args: Any) -> None: ... # PYI036: Bad star-args annotation 55 | async def __aexit__(self) -> None: ... # PYI036: Missing args | ^^^^^^ PYI036 -56 | +56 | 57 | class BadTwo: | @@ -45,7 +44,7 @@ PYI036.pyi:59:48: PYI036 All keyword-only arguments in `__aexit__` must have a d 58 | def __exit__(self, typ, exc, tb, weird_extra_arg) -> None: ... # PYI036: Extra arg must have default 59 | async def __aexit__(self, typ, exc, tb, *, weird_extra_arg1, weird_extra_arg2) -> None: ...# PYI036: kwargs must have default | ^^^^^^^^^^^^^^^^ PYI036 -60 | +60 | 61 | class BadThree: | @@ -55,54 +54,54 @@ PYI036.pyi:59:66: PYI036 All keyword-only arguments in `__aexit__` must have a d 58 | def __exit__(self, typ, exc, tb, weird_extra_arg) -> None: ... # PYI036: Extra arg must have default 59 | async def __aexit__(self, typ, exc, tb, *, weird_extra_arg1, weird_extra_arg2) -> None: ...# PYI036: kwargs must have default | ^^^^^^^^^^^^^^^^ PYI036 -60 | +60 | 61 | class BadThree: | PYI036.pyi:62:29: PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None` | 61 | class BadThree: -62 | def __exit__(self, typ: type[BaseException], exc: BaseException | None, tb: TracebackType | None) -> None: ... # PYI036: First arg has bad annotation +62 | def __exit__(self, typ: type[BaseException], exc: BaseException | None, tb: TracebackType | None) -> None: ... # PYI036: First arg… | ^^^^^^^^^^^^^^^^^^^ PYI036 -63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI036: Second arg has bad annotation +63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI0… | PYI036.pyi:63:73: PYI036 The second argument in `__aexit__` should be annotated with `object` or `BaseException | None` | 61 | class BadThree: -62 | def __exit__(self, typ: type[BaseException], exc: BaseException | None, tb: TracebackType | None) -> None: ... # PYI036: First arg has bad annotation -63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI036: Second arg has bad annotation +62 | def __exit__(self, typ: type[BaseException], exc: BaseException | None, tb: TracebackType | None) -> None: ... # PYI036: First arg… +63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI0… | ^^^^^^^^^^^^^ PYI036 -64 | +64 | 65 | class BadFour: | PYI036.pyi:63:94: PYI036 The third argument in `__aexit__` should be annotated with `object` or `types.TracebackType | None` | 61 | class BadThree: -62 | def __exit__(self, typ: type[BaseException], exc: BaseException | None, tb: TracebackType | None) -> None: ... # PYI036: First arg has bad annotation -63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI036: Second arg has bad annotation +62 | def __exit__(self, typ: type[BaseException], exc: BaseException | None, tb: TracebackType | None) -> None: ... # PYI036: First arg… +63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI0… | ^^^^^^^^^^^^^ PYI036 -64 | +64 | 65 | class BadFour: | PYI036.pyi:66:111: PYI036 The third argument in `__exit__` should be annotated with `object` or `types.TracebackType | None` | -65 | class BadFour: -66 | def __exit__(self, typ: typing.Optional[type[BaseException]], exc: typing.Union[BaseException, None], tb: TracebackType) -> None: ... # PYI036: Third arg has bad annotation - | ^^^^^^^^^^^^^ PYI036 -67 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, int]) -> bool | None: ... # PYI036: Third arg has bad annotation +65 | … +66 | …xception]], exc: typing.Union[BaseException, None], tb: TracebackType) -> None: ... # PYI036: Third arg has bad annotation + | ^^^^^^^^^^^^^ PYI036 +67 | …n] | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, int]) -> bool | None: ... # PYI036: Third arg has bad… | PYI036.pyi:67:101: PYI036 The third argument in `__aexit__` should be annotated with `object` or `types.TracebackType | None` | -65 | class BadFour: -66 | def __exit__(self, typ: typing.Optional[type[BaseException]], exc: typing.Union[BaseException, None], tb: TracebackType) -> None: ... # PYI036: Third arg has bad annotation -67 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, int]) -> bool | None: ... # PYI036: Third arg has bad annotation - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI036 -68 | -69 | class BadFive: +65 | … +66 | …eption]], exc: typing.Union[BaseException, None], tb: TracebackType) -> None: ... # PYI036: Third arg has bad annotation +67 | … | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, int]) -> bool | None: ... # PYI036: Third arg has bad a… + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI036 +68 | … +69 | … | PYI036.pyi:70:29: PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None` @@ -110,7 +109,7 @@ PYI036.pyi:70:29: PYI036 The first argument in `__exit__` should be annotated wi 69 | class BadFive: 70 | def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation | ^^^^^^^^^^^^^^^^^^^^ PYI036 -71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotation +71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotati… | PYI036.pyi:70:58: PYI036 [*] Star-args in `__exit__` should be annotated with `object` @@ -118,7 +117,7 @@ PYI036.pyi:70:58: PYI036 [*] Star-args in `__exit__` should be annotated with `o 69 | class BadFive: 70 | def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation | ^^^^^^^^^ PYI036 -71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotation +71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotati… | = help: Annotate star-args with `object` @@ -136,9 +135,9 @@ PYI036.pyi:71:74: PYI036 [*] Star-args in `__aexit__` should be annotated with ` | 69 | class BadFive: 70 | def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation -71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotation +71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotati… | ^^^ PYI036 -72 | +72 | 73 | class BadSix: | = help: Annotate star-args with `object` @@ -183,7 +182,7 @@ PYI036.pyi:90:95: PYI036 The third argument in `__aexit__` should be annotated w 89 | def __exit__(self, typ: type[Exception] | None, exc: BaseException | None, tb: TracebackType | None, /) -> None: ... 90 | async def __aexit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: TracebackType, /) -> None: ... | ^^^^^^^^^^^^^ PYI036 -91 | +91 | 92 | # Definitions not in a class scope can do whatever, we don't care | @@ -193,7 +192,7 @@ PYI036.pyi:159:17: PYI036 Annotations for a three-argument `__exit__` overload ( 158 | @overload 159 | def __exit__(self, exc_typ: Exception, exc: Exception, tb: TracebackType) -> None: ... # PYI036 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI036 -160 | +160 | 161 | class UnacceptableOverload2: | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI052_PYI052.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI052_PYI052.pyi.snap index 4fd76e3458b04..210dcc1918337 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI052_PYI052.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI052_PYI052.pyi.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- PYI052.pyi:14:10: PYI052 Need type annotation for `field5` | 12 | field43: int = -0xFFFFFFFF 13 | field44: int = -1234567890 -14 | field5 = 0 # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") # Y052 Need type annotation for "field5" +14 | field5 = 0 # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") # Y052 Need ty… | ^ PYI052 15 | field6 = 0 # Y052 Need type annotation for "field6" 16 | field7 = b"" # Y052 Need type annotation for "field7" @@ -15,7 +14,7 @@ PYI052.pyi:14:10: PYI052 Need type annotation for `field5` PYI052.pyi:15:10: PYI052 Need type annotation for `field6` | 13 | field44: int = -1234567890 -14 | field5 = 0 # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") # Y052 Need type annotation for "field5" +14 | field5 = 0 # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") # Y052 Need ty… 15 | field6 = 0 # Y052 Need type annotation for "field6" | ^ PYI052 16 | field7 = b"" # Y052 Need type annotation for "field7" @@ -24,7 +23,7 @@ PYI052.pyi:15:10: PYI052 Need type annotation for `field6` PYI052.pyi:16:10: PYI052 Need type annotation for `field7` | -14 | field5 = 0 # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") # Y052 Need type annotation for "field5" +14 | field5 = 0 # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") # Y052 Need ty… 15 | field6 = 0 # Y052 Need type annotation for "field6" 16 | field7 = b"" # Y052 Need type annotation for "field7" | ^^^ PYI052 diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI066_PYI066.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI066_PYI066.pyi.snap index 706fc9d07dbe8..3d8cec865cbd9 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI066_PYI066.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI066_PYI066.pyi.snap @@ -5,8 +5,8 @@ snapshot_kind: text PYI066.pyi:3:4: PYI066 Put branches for newer Python versions first when branching on `sys.version_info` comparisons | 1 | import sys -2 | -3 | if sys.version_info < (3, 10): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if sys.version_info >= (3, 10)" +2 | +3 | if sys.version_info < (3, 10): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if s… | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI066 4 | def foo(x): ... 5 | else: @@ -15,28 +15,28 @@ PYI066.pyi:3:4: PYI066 Put branches for newer Python versions first when branchi PYI066.pyi:8:4: PYI066 Put branches for newer Python versions first when branching on `sys.version_info` comparisons | 6 | def foo(x, *, bar=True): ... - 7 | - 8 | if sys.version_info < (3, 8): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if sys.version_info >= (3, 8)" + 7 | + 8 | if sys.version_info < (3, 8): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if s… | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI066 9 | def bar(x): ... -10 | elif sys.version_info < (3, 9): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if sys.version_info >= (3, 9)" +10 | elif sys.version_info < (3, 9): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if… | PYI066.pyi:10:6: PYI066 Put branches for newer Python versions first when branching on `sys.version_info` comparisons | - 8 | if sys.version_info < (3, 8): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if sys.version_info >= (3, 8)" + 8 | if sys.version_info < (3, 8): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if s… 9 | def bar(x): ... -10 | elif sys.version_info < (3, 9): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if sys.version_info >= (3, 9)" +10 | elif sys.version_info < (3, 9): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if… | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI066 11 | def bar(x, *, bar=True): ... -12 | elif sys.version_info < (3, 11): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if sys.version_info >= (3, 10)" +12 | elif sys.version_info < (3, 11): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "i… | PYI066.pyi:12:6: PYI066 Put branches for newer Python versions first when branching on `sys.version_info` comparisons | -10 | elif sys.version_info < (3, 9): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if sys.version_info >= (3, 9)" +10 | elif sys.version_info < (3, 9): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if… 11 | def bar(x, *, bar=True): ... -12 | elif sys.version_info < (3, 11): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if sys.version_info >= (3, 10)" +12 | elif sys.version_info < (3, 11): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "i… | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI066 13 | def bar(x, *, bar=True, baz=False): ... 14 | else: @@ -46,7 +46,7 @@ PYI066.pyi:20:6: PYI066 Put branches for newer Python versions first when branch | 18 | if sys.version_info >= (3, 5): 19 | ... -20 | elif sys.version_info < (3, 9): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if sys.version_info >= (3, 10)" +20 | elif sys.version_info < (3, 9): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if… | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI066 21 | ... 22 | else: diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote3.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote3.py.snap index be78a34c83800..8e70e33c741eb 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote3.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote3.py.snap @@ -4,10 +4,10 @@ source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs quote3.py:4:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block | 2 | from typing import Literal, Union -3 | +3 | 4 | from django.contrib.auth.models import AbstractBaseUser | ^^^^^^^^^^^^^^^^ TC002 -5 | +5 | 6 | def test_union_literal_mixed_quotes(user: AbstractBaseUser[Union[Literal['active', "inactive"], str]]): | = help: Move into type-checking block @@ -31,10 +31,10 @@ quote3.py:4:44: TC002 [*] Move third-party import `django.contrib.auth.models.Ab quote3.py:13:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block | 11 | from typing import Callable, Literal -12 | +12 | 13 | from django.contrib.auth.models import AbstractBaseUser | ^^^^^^^^^^^^^^^^ TC002 -14 | +14 | 15 | def test_callable_literal_mixed_quotes(callable_fn: AbstractBaseUser[Callable[["int", Literal['admin', "user"]], 'bool']]): | = help: Move into type-checking block @@ -62,11 +62,11 @@ quote3.py:13:44: TC002 [*] Move third-party import `django.contrib.auth.models.A quote3.py:22:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block | 20 | from typing import Annotated, Callable, Literal -21 | +21 | 22 | from django.contrib.auth.models import AbstractBaseUser | ^^^^^^^^^^^^^^^^ TC002 -23 | -24 | def test_callable_annotated_literal(callable_fn: AbstractBaseUser[Callable[[int, Annotated[str, Literal['active', "inactive"]]], bool]]): +23 | +24 | def test_callable_annotated_literal(callable_fn: AbstractBaseUser[Callable[[int, Annotated[str, Literal['active', "inactive"]]], b… | = help: Move into type-checking block @@ -93,10 +93,10 @@ quote3.py:22:44: TC002 [*] Move third-party import `django.contrib.auth.models.A quote3.py:31:37: TC002 [*] Move third-party import `django.contrib.auth.models` into a type-checking block | 29 | from typing import literal -30 | +30 | 31 | from django.contrib.auth import models | ^^^^^^ TC002 -32 | +32 | 33 | def test_attribute(arg: models.AbstractBaseUser["int"]): | = help: Move into type-checking block @@ -124,10 +124,10 @@ quote3.py:31:37: TC002 [*] Move third-party import `django.contrib.auth.models` quote3.py:40:37: TC002 [*] Move third-party import `django.contrib.auth.models` into a type-checking block | 38 | from typing import Literal -39 | +39 | 40 | from django.contrib.auth import models | ^^^^^^ TC002 -41 | +41 | 42 | def test_attribute_typing_literal(arg: models.AbstractBaseUser[Literal["admin"]]): | = help: Move into type-checking block @@ -158,7 +158,7 @@ quote3.py:59:29: TC002 [*] Move third-party import `third_party.Type` into a typ 58 | from typing import Literal 59 | from third_party import Type | ^^^^ TC002 -60 | +60 | 61 | def test_string_contains_opposite_quote(self, type1: Type[Literal["'"]], type2: Type[Literal["\'"]]): | = help: Move into type-checking block @@ -189,7 +189,7 @@ quote3.py:67:29: TC002 [*] Move third-party import `third_party.Type` into a typ 66 | from typing import Literal 67 | from third_party import Type | ^^^^ TC002 -68 | +68 | 69 | def test_quote_contains_backslash(self, type1: Type[Literal["\n"]], type2: Type[Literal["\""]]): | = help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E231_E23.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E231_E23.py.snap index 1a9c7a89ff57f..8846098bcc9b5 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E231_E23.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E231_E23.py.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E23.py:2:7: E231 [*] Missing whitespace after ',' | @@ -107,7 +106,7 @@ E23.py:33:6: E231 [*] Missing whitespace after ',' 32 | # E231 33 | f"{(a,b)}" | ^ E231 -34 | +34 | 35 | # Okay because it's hard to differentiate between the usages of a colon in a f-string | = help: Add missing whitespace @@ -127,7 +126,7 @@ E23.py:47:37: E231 [*] Missing whitespace after ':' 46 | #: E231 47 | {len(f's3://{self.s3_bucket_name}/'):1} | ^ E231 -48 | +48 | 49 | #: Okay | = help: Add missing whitespace @@ -604,7 +603,7 @@ E23.py:112:6: E231 [*] Missing whitespace after ':' E23.py:116:18: E231 [*] Missing whitespace after ':' | 114 | pass -115 | +115 | 116 | class PEP696Bad[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]: | ^ E231 117 | def pep_696_bad_method[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]( @@ -625,7 +624,7 @@ E23.py:116:18: E231 [*] Missing whitespace after ':' E23.py:116:40: E231 [*] Missing whitespace after ':' | 114 | pass -115 | +115 | 116 | class PEP696Bad[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]: | ^ E231 117 | def pep_696_bad_method[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]( @@ -646,7 +645,7 @@ E23.py:116:40: E231 [*] Missing whitespace after ':' E23.py:116:70: E231 [*] Missing whitespace after ':' | 114 | pass -115 | +115 | 116 | class PEP696Bad[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]: | ^ E231 117 | def pep_696_bad_method[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]( @@ -790,10 +789,10 @@ E23.py:121:10: E231 [*] Missing whitespace after ':' E23.py:125:32: E231 [*] Missing whitespace after ':' | 123 | pass -124 | +124 | 125 | class PEP696BadWithEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](): | ^ E231 -126 | class IndentedPEP696BadWithNonEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](object, something_dynamic[x::-1]): +126 | class IndentedPEP696BadWithNonEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](object, something_d… 127 | pass | = help: Add missing whitespace @@ -811,10 +810,10 @@ E23.py:125:32: E231 [*] Missing whitespace after ':' E23.py:125:54: E231 [*] Missing whitespace after ':' | 123 | pass -124 | +124 | 125 | class PEP696BadWithEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](): | ^ E231 -126 | class IndentedPEP696BadWithNonEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](object, something_dynamic[x::-1]): +126 | class IndentedPEP696BadWithNonEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](object, something_d… 127 | pass | = help: Add missing whitespace @@ -832,10 +831,10 @@ E23.py:125:54: E231 [*] Missing whitespace after ':' E23.py:125:84: E231 [*] Missing whitespace after ':' | 123 | pass -124 | +124 | 125 | class PEP696BadWithEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](): | ^ E231 -126 | class IndentedPEP696BadWithNonEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](object, something_dynamic[x::-1]): +126 | class IndentedPEP696BadWithNonEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](object, something_d… 127 | pass | = help: Add missing whitespace @@ -853,7 +852,7 @@ E23.py:125:84: E231 [*] Missing whitespace after ':' E23.py:126:47: E231 [*] Missing whitespace after ':' | 125 | class PEP696BadWithEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](): -126 | class IndentedPEP696BadWithNonEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](object, something_dynamic[x::-1]): +126 | class IndentedPEP696BadWithNonEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](object, something_d… | ^ E231 127 | pass | @@ -872,7 +871,7 @@ E23.py:126:47: E231 [*] Missing whitespace after ':' E23.py:126:69: E231 [*] Missing whitespace after ':' | 125 | class PEP696BadWithEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](): -126 | class IndentedPEP696BadWithNonEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](object, something_dynamic[x::-1]): +126 | class IndentedPEP696BadWithNonEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](object, something_d… | ^ E231 127 | pass | @@ -891,7 +890,7 @@ E23.py:126:69: E231 [*] Missing whitespace after ':' E23.py:126:99: E231 [*] Missing whitespace after ':' | 125 | class PEP696BadWithEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](): -126 | class IndentedPEP696BadWithNonEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](object, something_dynamic[x::-1]): +126 | class IndentedPEP696BadWithNonEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](object, something_d… | ^ E231 127 | pass | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E501_E501.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E501_E501.py.snap index 457411baaa622..b7eab7d0159f6 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E501_E501.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E501_E501.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E501.py:5:89: E501 Line too long (123 > 88) | 3 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 -4 | +4 | 5 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 6 | """ @@ -50,9 +49,9 @@ E501.py:43:89: E501 Line too long (105 > 88) E501.py:83:89: E501 Line too long (147 > 88) | -81 | class Bar: -82 | """ -83 | This is a long sentence that ends with a shortened URL and, therefore, could easily be broken across multiple lines ([source](https://ruff.rs)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 -84 | """ +81 | … +82 | … +83 | … URL and, therefore, could easily be broken across multiple lines ([source](https://ruff.rs)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 +84 | … | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__task_tags_false.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__task_tags_false.snap index 2efa2608b24fd..6dfc2c571a233 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__task_tags_false.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__task_tags_false.snap @@ -1,77 +1,76 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- E501_1.py:1:89: E501 Line too long (149 > 88) | -1 | # TODO: comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 -2 | # TODO(charlie): comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -3 | # TODO comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +1 | …ask-tags sometimes are longer than line-length so that you can easily find them with `git grep` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 +2 | …figured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +3 | …sk-tags sometimes are longer than line-length so that you can easily find them with `git grep` | E501_1.py:2:89: E501 Line too long (158 > 88) | -1 | # TODO: comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -2 | # TODO(charlie): comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 -3 | # TODO comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -4 | # TODO comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +1 | …ags sometimes are longer than line-length so that you can easily find them with `git grep` +2 | …ed task-tags sometimes are longer than line-length so that you can easily find them with `git grep` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 +3 | …gs sometimes are longer than line-length so that you can easily find them with `git grep` +4 | …task-tags sometimes are longer than line-length so that you can easily find them with `git grep` | E501_1.py:3:89: E501 Line too long (148 > 88) | -1 | # TODO: comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -2 | # TODO(charlie): comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -3 | # TODO comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 -4 | # TODO comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -5 | # FIXME: comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +1 | …ask-tags sometimes are longer than line-length so that you can easily find them with `git grep` +2 | …figured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +3 | …sk-tags sometimes are longer than line-length so that you can easily find them with `git grep` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 +4 | …ured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +5 | …task-tags sometimes are longer than line-length so that you can easily find them with `git grep` | E501_1.py:4:89: E501 Line too long (155 > 88) | -2 | # TODO(charlie): comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -3 | # TODO comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -4 | # TODO comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 -5 | # FIXME: comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -6 | # FIXME comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +2 | …ured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +3 | …tags sometimes are longer than line-length so that you can easily find them with `git grep` +4 | …d task-tags sometimes are longer than line-length so that you can easily find them with `git grep` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 +5 | …k-tags sometimes are longer than line-length so that you can easily find them with `git grep` +6 | …-tags sometimes are longer than line-length so that you can easily find them with `git grep` | E501_1.py:5:89: E501 Line too long (150 > 88) | -3 | # TODO comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -4 | # TODO comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -5 | # FIXME: comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 -6 | # FIXME comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -7 | # FIXME comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +3 | …k-tags sometimes are longer than line-length so that you can easily find them with `git grep` +4 | …red task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +5 | …ask-tags sometimes are longer than line-length so that you can easily find them with `git grep` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 +6 | …sk-tags sometimes are longer than line-length so that you can easily find them with `git grep` +7 | …ured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` | E501_1.py:6:89: E501 Line too long (149 > 88) | -4 | # TODO comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -5 | # FIXME: comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -6 | # FIXME comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 -7 | # FIXME comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -8 | # FIXME(charlie): comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +4 | …ured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +5 | …task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +6 | …ask-tags sometimes are longer than line-length so that you can easily find them with `git grep` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 +7 | …gured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +8 | …nfigured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` | E501_1.py:7:89: E501 Line too long (156 > 88) | -5 | # FIXME: comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -6 | # FIXME comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -7 | # FIXME comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 -8 | # FIXME(charlie): comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +5 | …-tags sometimes are longer than line-length so that you can easily find them with `git grep` +6 | …tags sometimes are longer than line-length so that you can easily find them with `git grep` +7 | …d task-tags sometimes are longer than line-length so that you can easily find them with `git grep` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 +8 | …ured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` | E501_1.py:8:89: E501 Line too long (159 > 88) | -6 | # FIXME comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -7 | # FIXME comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -8 | # FIXME(charlie): comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 +6 | …ags sometimes are longer than line-length so that you can easily find them with `git grep` +7 | … task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +8 | …red task-tags sometimes are longer than line-length so that you can easily find them with `git grep` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_17.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_17.py.snap index 82e9a41c3bb66..ad86315cccf85 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_17.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_17.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- F821_17.py:16:12: F821 Undefined name `DoesNotExist` | 14 | # Types used in aliased assignment must exist -15 | +15 | 16 | type Foo = DoesNotExist # F821: Undefined name `DoesNotExist` | ^^^^^^^^^^^^ F821 17 | type Foo = list[DoesNotExist] # F821: Undefined name `DoesNotExist` @@ -16,7 +15,7 @@ F821_17.py:17:17: F821 Undefined name `DoesNotExist` 16 | type Foo = DoesNotExist # F821: Undefined name `DoesNotExist` 17 | type Foo = list[DoesNotExist] # F821: Undefined name `DoesNotExist` | ^^^^^^^^^^^^ F821 -18 | +18 | 19 | # Type parameters do not escape alias scopes | @@ -25,17 +24,17 @@ F821_17.py:22:1: F821 Undefined name `T` 21 | type Foo[T] = T 22 | T # F821: Undefined name `T` - not accessible afterward alias scope | ^ F821 -23 | +23 | 24 | # Type parameters in functions | F821_17.py:39:17: F821 Undefined name `T` | 37 | from some_library import some_decorator -38 | +38 | 39 | @some_decorator(T) # F821: Undefined name `T` - not accessible in decorators | ^ F821 -40 | +40 | 41 | def foo[T](t: T) -> None: ... | @@ -51,7 +50,7 @@ F821_17.py:64:17: F821 Undefined name `T` 63 | from some_library import some_decorator 64 | @some_decorator(T) # F821: Undefined name `T` - not accessible in decorators | ^ F821 -65 | +65 | 66 | class Foo[T](list[T]): ... | @@ -60,14 +59,14 @@ F821_17.py:67:1: F821 Undefined name `T` 66 | class Foo[T](list[T]): ... 67 | T # F821: Undefined name `T` - not accessible after class scope | ^ F821 -68 | +68 | 69 | # Types specified in bounds should exist | F821_17.py:71:13: F821 Undefined name `DoesNotExist` | 69 | # Types specified in bounds should exist -70 | +70 | 71 | type Foo[T: DoesNotExist] = T # F821: Undefined name `DoesNotExist` | ^^^^^^^^^^^^ F821 72 | def foo[T: DoesNotExist](t: T) -> T: return t # F821: Undefined name `DoesNotExist` @@ -88,14 +87,14 @@ F821_17.py:73:14: F821 Undefined name `DoesNotExist` 72 | def foo[T: DoesNotExist](t: T) -> T: return t # F821: Undefined name `DoesNotExist` 73 | class Foo[T: DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` | ^^^^^^^^^^^^ F821 -74 | +74 | 75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | F821_17.py:75:14: F821 Undefined name `DoesNotExist1` | 73 | class Foo[T: DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` -74 | +74 | 75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | ^^^^^^^^^^^^^ F821 76 | def foo[T: (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` @@ -105,7 +104,7 @@ F821_17.py:75:14: F821 Undefined name `DoesNotExist1` F821_17.py:75:29: F821 Undefined name `DoesNotExist2` | 73 | class Foo[T: DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` -74 | +74 | 75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | ^^^^^^^^^^^^^ F821 76 | def foo[T: (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` @@ -134,7 +133,7 @@ F821_17.py:77:15: F821 Undefined name `DoesNotExist1` 76 | def foo[T: (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` 77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | ^^^^^^^^^^^^^ F821 -78 | +78 | 79 | # Same in defaults | @@ -144,14 +143,14 @@ F821_17.py:77:30: F821 Undefined name `DoesNotExist2` 76 | def foo[T: (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` 77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | ^^^^^^^^^^^^^ F821 -78 | +78 | 79 | # Same in defaults | F821_17.py:81:14: F821 Undefined name `DoesNotExist` | 79 | # Same in defaults -80 | +80 | 81 | type Foo[T = DoesNotExist] = T # F821: Undefined name `DoesNotExist` | ^^^^^^^^^^^^ F821 82 | def foo[T = DoesNotExist](t: T) -> T: return t # F821: Undefined name `DoesNotExist` @@ -172,34 +171,34 @@ F821_17.py:83:15: F821 Undefined name `DoesNotExist` 82 | def foo[T = DoesNotExist](t: T) -> T: return t # F821: Undefined name `DoesNotExist` 83 | class Foo[T = DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` | ^^^^^^^^^^^^ F821 -84 | +84 | 85 | type Foo[T = (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | F821_17.py:85:15: F821 Undefined name `DoesNotExist1` | 83 | class Foo[T = DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` -84 | +84 | 85 | type Foo[T = (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | ^^^^^^^^^^^^^ F821 -86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` +86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist… 87 | class Foo[T = (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | F821_17.py:85:30: F821 Undefined name `DoesNotExist2` | 83 | class Foo[T = DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` -84 | +84 | 85 | type Foo[T = (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | ^^^^^^^^^^^^^ F821 -86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` +86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist… 87 | class Foo[T = (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | F821_17.py:86:14: F821 Undefined name `DoesNotExist1` | 85 | type Foo[T = (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` -86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` +86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist… | ^^^^^^^^^^^^^ F821 87 | class Foo[T = (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | @@ -207,7 +206,7 @@ F821_17.py:86:14: F821 Undefined name `DoesNotExist1` F821_17.py:86:29: F821 Undefined name `DoesNotExist2` | 85 | type Foo[T = (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` -86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` +86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist… | ^^^^^^^^^^^^^ F821 87 | class Foo[T = (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | @@ -215,27 +214,27 @@ F821_17.py:86:29: F821 Undefined name `DoesNotExist2` F821_17.py:87:16: F821 Undefined name `DoesNotExist1` | 85 | type Foo[T = (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` -86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` +86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist… 87 | class Foo[T = (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | ^^^^^^^^^^^^^ F821 -88 | +88 | 89 | # Type parameters in nested classes | F821_17.py:87:31: F821 Undefined name `DoesNotExist2` | 85 | type Foo[T = (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` -86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` +86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist… 87 | class Foo[T = (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | ^^^^^^^^^^^^^ F821 -88 | +88 | 89 | # Type parameters in nested classes | F821_17.py:102:52: F821 Undefined name `t` | 100 | return x -101 | +101 | 102 | def cannot_access_parent_variable(self, x: t) -> t: # F821: Undefined name `T` | ^ F821 103 | t # F821: Undefined name `t` @@ -245,7 +244,7 @@ F821_17.py:102:52: F821 Undefined name `t` F821_17.py:102:58: F821 Undefined name `t` | 100 | return x -101 | +101 | 102 | def cannot_access_parent_variable(self, x: t) -> t: # F821: Undefined name `T` | ^ F821 103 | t # F821: Undefined name `t` diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_boolean_expressions.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_boolean_expressions.snap index c5da76519d183..3bab1afdea29a 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_boolean_expressions.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_boolean_expressions.snap @@ -1,6 +1,5 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- too_many_boolean_expressions.py:11:6: PLR0916 Too many Boolean expressions (6 > 5) | @@ -169,7 +168,7 @@ too_many_boolean_expressions.py:43:6: PLR0916 Too many Boolean expressions (22 > 43 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 44 | ... -45 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and w: +45 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and … | too_many_boolean_expressions.py:45:6: PLR0916 Too many Boolean expressions (23 > 5) @@ -179,7 +178,7 @@ too_many_boolean_expressions.py:45:6: PLR0916 Too many Boolean expressions (23 > 45 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and w: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 46 | ... -47 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and w and x: +47 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and w and … | too_many_boolean_expressions.py:47:6: PLR0916 Too many Boolean expressions (24 > 5) @@ -189,7 +188,7 @@ too_many_boolean_expressions.py:47:6: PLR0916 Too many Boolean expressions (24 > 47 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and w and x: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 48 | ... -49 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and w and x and y: +49 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and w and x and … | too_many_boolean_expressions.py:49:6: PLR0916 Too many Boolean expressions (25 > 5) @@ -199,7 +198,7 @@ too_many_boolean_expressions.py:49:6: PLR0916 Too many Boolean expressions (25 > 49 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and w and x and y: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 50 | ... -51 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and w and x and y and z: +51 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and w and x and y and … | too_many_boolean_expressions.py:51:6: PLR0916 Too many Boolean expressions (26 > 5) diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP031_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP031_0.py.snap index 79c32ccea26e8..129a49cc93db9 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP031_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP031_0.py.snap @@ -6,7 +6,7 @@ UP031_0.py:4:7: UP031 [*] Use format specifiers instead of percent format 3 | # UP031 4 | print('%s %s' % (a, b)) | ^^^^^^^^^^^^^^^^ UP031 -5 | +5 | 6 | print('%s%s' % (a, b)) | = help: Replace with format specifiers @@ -24,10 +24,10 @@ UP031_0.py:4:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:6:7: UP031 [*] Use format specifiers instead of percent format | 4 | print('%s %s' % (a, b)) -5 | +5 | 6 | print('%s%s' % (a, b)) | ^^^^^^^^^^^^^^^ UP031 -7 | +7 | 8 | print("trivial" % ()) | = help: Replace with format specifiers @@ -45,10 +45,10 @@ UP031_0.py:6:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:8:7: UP031 [*] Use format specifiers instead of percent format | 6 | print('%s%s' % (a, b)) - 7 | + 7 | 8 | print("trivial" % ()) | ^^^^^^^^^^^^^^ UP031 - 9 | + 9 | 10 | print("%s" % ("simple",)) | = help: Replace with format specifiers @@ -66,10 +66,10 @@ UP031_0.py:8:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:10:7: UP031 [*] Use format specifiers instead of percent format | 8 | print("trivial" % ()) - 9 | + 9 | 10 | print("%s" % ("simple",)) | ^^^^^^^^^^^^^^^^^^ UP031 -11 | +11 | 12 | print("%s" % ("%s" % ("nested",),)) | = help: Replace with format specifiers @@ -87,10 +87,10 @@ UP031_0.py:10:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:12:7: UP031 [*] Use format specifiers instead of percent format | 10 | print("%s" % ("simple",)) -11 | +11 | 12 | print("%s" % ("%s" % ("nested",),)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 -13 | +13 | 14 | print("%s%% percent" % (15,)) | = help: Replace with format specifiers @@ -108,10 +108,10 @@ UP031_0.py:12:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:12:15: UP031 [*] Use format specifiers instead of percent format | 10 | print("%s" % ("simple",)) -11 | +11 | 12 | print("%s" % ("%s" % ("nested",),)) | ^^^^^^^^^^^^^^^^^^ UP031 -13 | +13 | 14 | print("%s%% percent" % (15,)) | = help: Replace with format specifiers @@ -129,10 +129,10 @@ UP031_0.py:12:15: UP031 [*] Use format specifiers instead of percent format UP031_0.py:14:7: UP031 [*] Use format specifiers instead of percent format | 12 | print("%s" % ("%s" % ("nested",),)) -13 | +13 | 14 | print("%s%% percent" % (15,)) | ^^^^^^^^^^^^^^^^^^^^^^ UP031 -15 | +15 | 16 | print("%f" % (15,)) | = help: Replace with format specifiers @@ -150,10 +150,10 @@ UP031_0.py:14:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:16:7: UP031 [*] Use format specifiers instead of percent format | 14 | print("%s%% percent" % (15,)) -15 | +15 | 16 | print("%f" % (15,)) | ^^^^^^^^^^^^ UP031 -17 | +17 | 18 | print("%.f" % (15,)) | = help: Replace with format specifiers @@ -171,10 +171,10 @@ UP031_0.py:16:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:18:7: UP031 [*] Use format specifiers instead of percent format | 16 | print("%f" % (15,)) -17 | +17 | 18 | print("%.f" % (15,)) | ^^^^^^^^^^^^^ UP031 -19 | +19 | 20 | print("%.3f" % (15,)) | = help: Replace with format specifiers @@ -192,10 +192,10 @@ UP031_0.py:18:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:20:7: UP031 [*] Use format specifiers instead of percent format | 18 | print("%.f" % (15,)) -19 | +19 | 20 | print("%.3f" % (15,)) | ^^^^^^^^^^^^^^ UP031 -21 | +21 | 22 | print("%3f" % (15,)) | = help: Replace with format specifiers @@ -213,10 +213,10 @@ UP031_0.py:20:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:22:7: UP031 [*] Use format specifiers instead of percent format | 20 | print("%.3f" % (15,)) -21 | +21 | 22 | print("%3f" % (15,)) | ^^^^^^^^^^^^^ UP031 -23 | +23 | 24 | print("%-5f" % (5,)) | = help: Replace with format specifiers @@ -234,10 +234,10 @@ UP031_0.py:22:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:24:7: UP031 [*] Use format specifiers instead of percent format | 22 | print("%3f" % (15,)) -23 | +23 | 24 | print("%-5f" % (5,)) | ^^^^^^^^^^^^^ UP031 -25 | +25 | 26 | print("%9f" % (5,)) | = help: Replace with format specifiers @@ -255,10 +255,10 @@ UP031_0.py:24:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:26:7: UP031 [*] Use format specifiers instead of percent format | 24 | print("%-5f" % (5,)) -25 | +25 | 26 | print("%9f" % (5,)) | ^^^^^^^^^^^^ UP031 -27 | +27 | 28 | print("%#o" % (123,)) | = help: Replace with format specifiers @@ -276,10 +276,10 @@ UP031_0.py:26:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:28:7: UP031 [*] Use format specifiers instead of percent format | 26 | print("%9f" % (5,)) -27 | +27 | 28 | print("%#o" % (123,)) | ^^^^^^^^^^^^^^ UP031 -29 | +29 | 30 | print("brace {} %s" % (1,)) | = help: Replace with format specifiers @@ -297,10 +297,10 @@ UP031_0.py:28:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:30:7: UP031 [*] Use format specifiers instead of percent format | 28 | print("%#o" % (123,)) -29 | +29 | 30 | print("brace {} %s" % (1,)) | ^^^^^^^^^^^^^^^^^^^^ UP031 -31 | +31 | 32 | print(( | = help: Replace with format specifiers @@ -318,8 +318,7 @@ UP031_0.py:30:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:33:5: UP031 [*] Use format specifiers instead of percent format | 32 | print(( -33 | "foo %s " - | _____^ +33 | / "foo %s " 34 | | "bar %s" % (x, y) | |_____________________^ UP031 35 | )) @@ -341,8 +340,7 @@ UP031_0.py:33:5: UP031 [*] Use format specifiers instead of percent format UP031_0.py:38:3: UP031 [*] Use format specifiers instead of percent format | 37 | print( -38 | "%s" % ( - | ___^ +38 | / "%s" % ( 39 | | "trailing comma", 40 | | ) | |_________^ UP031 @@ -363,10 +361,10 @@ UP031_0.py:38:3: UP031 [*] Use format specifiers instead of percent format UP031_0.py:43:7: UP031 [*] Use format specifiers instead of percent format | 41 | ) -42 | +42 | 43 | print("foo %s " % (x,)) | ^^^^^^^^^^^^^^^^ UP031 -44 | +44 | 45 | print("%(k)s" % {"k": "v"}) | = help: Replace with format specifiers @@ -384,10 +382,10 @@ UP031_0.py:43:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:45:7: UP031 [*] Use format specifiers instead of percent format | 43 | print("foo %s " % (x,)) -44 | +44 | 45 | print("%(k)s" % {"k": "v"}) | ^^^^^^^^^^^^^^^^^^^^ UP031 -46 | +46 | 47 | print("%(k)s" % { | = help: Replace with format specifiers @@ -405,14 +403,14 @@ UP031_0.py:45:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:47:7: UP031 [*] Use format specifiers instead of percent format | 45 | print("%(k)s" % {"k": "v"}) -46 | +46 | 47 | print("%(k)s" % { | _______^ 48 | | "k": "v", 49 | | "i": "j" 50 | | }) | |_^ UP031 -51 | +51 | 52 | print("%(to_list)s" % {"to_list": []}) | = help: Replace with format specifiers @@ -436,10 +434,10 @@ UP031_0.py:47:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:52:7: UP031 [*] Use format specifiers instead of percent format | 50 | }) -51 | +51 | 52 | print("%(to_list)s" % {"to_list": []}) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 -53 | +53 | 54 | print("%(k)s" % {"k": "v", "i": 1, "j": []}) | = help: Replace with format specifiers @@ -457,10 +455,10 @@ UP031_0.py:52:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:54:7: UP031 [*] Use format specifiers instead of percent format | 52 | print("%(to_list)s" % {"to_list": []}) -53 | +53 | 54 | print("%(k)s" % {"k": "v", "i": 1, "j": []}) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 -55 | +55 | 56 | print("%(ab)s" % {"a" "b": 1}) | = help: Replace with format specifiers @@ -478,10 +476,10 @@ UP031_0.py:54:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:56:7: UP031 [*] Use format specifiers instead of percent format | 54 | print("%(k)s" % {"k": "v", "i": 1, "j": []}) -55 | +55 | 56 | print("%(ab)s" % {"a" "b": 1}) | ^^^^^^^^^^^^^^^^^^^^^^^ UP031 -57 | +57 | 58 | print("%(a)s" % {"a" : 1}) | = help: Replace with format specifiers @@ -499,7 +497,7 @@ UP031_0.py:56:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:58:7: UP031 [*] Use format specifiers instead of percent format | 56 | print("%(ab)s" % {"a" "b": 1}) -57 | +57 | 58 | print("%(a)s" % {"a" : 1}) | ^^^^^^^^^^^^^^^^^^^^^ UP031 | @@ -518,8 +516,7 @@ UP031_0.py:58:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:62:5: UP031 [*] Use format specifiers instead of percent format | 61 | print( -62 | "foo %(foo)s " - | _____^ +62 | / "foo %(foo)s " 63 | | "bar %(bar)s" % {"foo": x, "bar": y} | |________________________________________^ UP031 64 | ) @@ -542,8 +539,7 @@ UP031_0.py:68:5: UP031 [*] Use format specifiers instead of percent format | 66 | bar = {"bar": y} 67 | print( -68 | "foo %(foo)s " - | _____^ +68 | / "foo %(foo)s " 69 | | "bar %(bar)s" % {"foo": x, **bar} | |_____________________________________^ UP031 70 | ) @@ -565,10 +561,10 @@ UP031_0.py:68:5: UP031 [*] Use format specifiers instead of percent format UP031_0.py:72:7: UP031 [*] Use format specifiers instead of percent format | 70 | ) -71 | +71 | 72 | print("%s \N{snowman}" % (a,)) | ^^^^^^^^^^^^^^^^^^^^^^^ UP031 -73 | +73 | 74 | print("%(foo)s \N{snowman}" % {"foo": 1}) | = help: Replace with format specifiers @@ -586,10 +582,10 @@ UP031_0.py:72:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:74:7: UP031 [*] Use format specifiers instead of percent format | 72 | print("%s \N{snowman}" % (a,)) -73 | +73 | 74 | print("%(foo)s \N{snowman}" % {"foo": 1}) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 -75 | +75 | 76 | print(("foo %s " "bar %s") % (x, y)) | = help: Replace with format specifiers @@ -607,10 +603,10 @@ UP031_0.py:74:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:76:7: UP031 [*] Use format specifiers instead of percent format | 74 | print("%(foo)s \N{snowman}" % {"foo": 1}) -75 | +75 | 76 | print(("foo %s " "bar %s") % (x, y)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 -77 | +77 | 78 | # Single-value expressions | = help: Replace with format specifiers @@ -776,7 +772,7 @@ UP031_0.py:86:7: UP031 [*] Use format specifiers instead of percent format 85 | print('Hello %(arg)s' % bar.baz) 86 | print('Hello %(arg)s' % bar['bop']) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 -87 | +87 | 88 | # Hanging modulos | = help: Replace with format specifiers @@ -799,7 +795,7 @@ UP031_0.py:89:1: UP031 [*] Use format specifiers instead of percent format 91 | | "bar %s" 92 | | ) % (x, y) | |__________^ UP031 -93 | +93 | 94 | ( | = help: Replace with format specifiers @@ -821,13 +817,13 @@ UP031_0.py:89:1: UP031 [*] Use format specifiers instead of percent format UP031_0.py:94:1: UP031 [*] Use format specifiers instead of percent format | 92 | ) % (x, y) -93 | +93 | 94 | / ( 95 | | "foo %(foo)s " 96 | | "bar %(bar)s" 97 | | ) % {"foo": x, "bar": y} | |________________________^ UP031 -98 | +98 | 99 | ( | = help: Replace with format specifiers @@ -849,8 +845,7 @@ UP031_0.py:94:1: UP031 [*] Use format specifiers instead of percent format UP031_0.py:100:5: UP031 [*] Use format specifiers instead of percent format | 99 | ( -100 | """foo %s""" - | _____^ +100 | / """foo %s""" 101 | | % (x,) | |__________^ UP031 102 | ) @@ -871,8 +866,7 @@ UP031_0.py:100:5: UP031 [*] Use format specifiers instead of percent format UP031_0.py:105:5: UP031 [*] Use format specifiers instead of percent format | 104 | ( -105 | """ - | _____^ +105 | / """ 106 | | foo %s 107 | | """ 108 | | % (x,) @@ -897,7 +891,7 @@ UP031_0.py:105:5: UP031 [*] Use format specifiers instead of percent format UP031_0.py:111:1: UP031 [*] Use format specifiers instead of percent format | 109 | ) -110 | +110 | 111 | / "%s" % ( 112 | | x, # comment 113 | | ) @@ -919,12 +913,12 @@ UP031_0.py:116:8: UP031 [*] Use format specifiers instead of percent format | 116 | path = "%s-%s-%s.pem" % ( | ________^ -117 | | safe_domain_name(cn), # common name, which should be filename safe because it is IDNA-encoded, but in case of a malformed cert make sure it's ok to use as a filename +117 | | safe_domain_name(cn), # common name, which should be filename safe because it is IDNA-encoded, but in case of a malformed cert ma… 118 | | cert.not_valid_after.date().isoformat().replace("-", ""), # expiration date 119 | | hexlify(cert.fingerprint(hashes.SHA256())).decode("ascii")[0:8], # fingerprint prefix 120 | | ) | |_^ UP031 -121 | +121 | 122 | # UP031 (no longer false negatives; now offer potentially unsafe fixes) | = help: Replace with format specifiers @@ -944,7 +938,7 @@ UP031_0.py:123:1: UP031 [*] Use format specifiers instead of percent format 122 | # UP031 (no longer false negatives; now offer potentially unsafe fixes) 123 | 'Hello %s' % bar | ^^^^^^^^^^^^^^^^ UP031 -124 | +124 | 125 | 'Hello %s' % bar.baz | = help: Replace with format specifiers @@ -962,10 +956,10 @@ UP031_0.py:123:1: UP031 [*] Use format specifiers instead of percent format UP031_0.py:125:1: UP031 [*] Use format specifiers instead of percent format | 123 | 'Hello %s' % bar -124 | +124 | 125 | 'Hello %s' % bar.baz | ^^^^^^^^^^^^^^^^^^^^ UP031 -126 | +126 | 127 | 'Hello %s' % bar['bop'] | = help: Replace with format specifiers @@ -983,10 +977,10 @@ UP031_0.py:125:1: UP031 [*] Use format specifiers instead of percent format UP031_0.py:127:1: UP031 [*] Use format specifiers instead of percent format | 125 | 'Hello %s' % bar.baz -126 | +126 | 127 | 'Hello %s' % bar['bop'] | ^^^^^^^^^^^^^^^^^^^^^^^ UP031 -128 | +128 | 129 | # Not a valid type annotation but this test shouldn't result in a panic. | = help: Replace with format specifiers @@ -1007,7 +1001,7 @@ UP031_0.py:131:5: UP031 [*] Use format specifiers instead of percent format 130 | # Refer: https://github.com/astral-sh/ruff/issues/11736 131 | x: "'%s + %s' % (1, 2)" | ^^^^^^^^^^^^^^^^^^ UP031 -132 | +132 | 133 | # See: https://github.com/astral-sh/ruff/issues/12421 | = help: Replace with format specifiers @@ -1110,7 +1104,7 @@ UP031_0.py:138:7: UP031 [*] Use format specifiers instead of percent format 137 | print("%.00002X" % 1) 138 | print("%.20X" % 1) | ^^^^^^^^^^^ UP031 -139 | +139 | 140 | print("%2X" % 1) | = help: Replace with format specifiers @@ -1128,7 +1122,7 @@ UP031_0.py:138:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:140:7: UP031 [*] Use format specifiers instead of percent format | 138 | print("%.20X" % 1) -139 | +139 | 140 | print("%2X" % 1) | ^^^^^^^^^ UP031 141 | print("%02X" % 1) @@ -1150,7 +1144,7 @@ UP031_0.py:141:7: UP031 [*] Use format specifiers instead of percent format 140 | print("%2X" % 1) 141 | print("%02X" % 1) | ^^^^^^^^^^ UP031 -142 | +142 | 143 | # UP031 (no longer false negatives, but offer no fix because of more complex syntax) | = help: Replace with format specifiers @@ -1168,10 +1162,10 @@ UP031_0.py:141:7: UP031 [*] Use format specifiers instead of percent format UP031_0.py:145:1: UP031 Use format specifiers instead of percent format | 143 | # UP031 (no longer false negatives, but offer no fix because of more complex syntax) -144 | +144 | 145 | "%d.%d" % (a, b) | ^^^^^^^ UP031 -146 | +146 | 147 | "%*s" % (5, "hi") | = help: Replace with format specifiers @@ -1179,10 +1173,10 @@ UP031_0.py:145:1: UP031 Use format specifiers instead of percent format UP031_0.py:147:1: UP031 Use format specifiers instead of percent format | 145 | "%d.%d" % (a, b) -146 | +146 | 147 | "%*s" % (5, "hi") | ^^^^^ UP031 -148 | +148 | 149 | "%d" % (flt,) | = help: Replace with format specifiers @@ -1190,10 +1184,10 @@ UP031_0.py:147:1: UP031 Use format specifiers instead of percent format UP031_0.py:149:1: UP031 Use format specifiers instead of percent format | 147 | "%*s" % (5, "hi") -148 | +148 | 149 | "%d" % (flt,) | ^^^^ UP031 -150 | +150 | 151 | "%c" % (some_string,) | = help: Replace with format specifiers @@ -1201,10 +1195,10 @@ UP031_0.py:149:1: UP031 Use format specifiers instead of percent format UP031_0.py:151:1: UP031 Use format specifiers instead of percent format | 149 | "%d" % (flt,) -150 | +150 | 151 | "%c" % (some_string,) | ^^^^ UP031 -152 | +152 | 153 | "%.2r" % (1.25) | = help: Replace with format specifiers @@ -1212,10 +1206,10 @@ UP031_0.py:151:1: UP031 Use format specifiers instead of percent format UP031_0.py:153:1: UP031 Use format specifiers instead of percent format | 151 | "%c" % (some_string,) -152 | +152 | 153 | "%.2r" % (1.25) | ^^^^^^ UP031 -154 | +154 | 155 | "%.*s" % (5, "hi") | = help: Replace with format specifiers @@ -1223,10 +1217,10 @@ UP031_0.py:153:1: UP031 Use format specifiers instead of percent format UP031_0.py:155:1: UP031 Use format specifiers instead of percent format | 153 | "%.2r" % (1.25) -154 | +154 | 155 | "%.*s" % (5, "hi") | ^^^^^^ UP031 -156 | +156 | 157 | "%i" % (flt,) | = help: Replace with format specifiers @@ -1234,10 +1228,10 @@ UP031_0.py:155:1: UP031 Use format specifiers instead of percent format UP031_0.py:157:1: UP031 Use format specifiers instead of percent format | 155 | "%.*s" % (5, "hi") -156 | +156 | 157 | "%i" % (flt,) | ^^^^ UP031 -158 | +158 | 159 | "%()s" % {"": "empty"} | = help: Replace with format specifiers @@ -1245,10 +1239,10 @@ UP031_0.py:157:1: UP031 Use format specifiers instead of percent format UP031_0.py:159:1: UP031 Use format specifiers instead of percent format | 157 | "%i" % (flt,) -158 | +158 | 159 | "%()s" % {"": "empty"} | ^^^^^^ UP031 -160 | +160 | 161 | "%s" % {"k": "v"} | = help: Replace with format specifiers @@ -1256,10 +1250,10 @@ UP031_0.py:159:1: UP031 Use format specifiers instead of percent format UP031_0.py:161:1: UP031 Use format specifiers instead of percent format | 159 | "%()s" % {"": "empty"} -160 | +160 | 161 | "%s" % {"k": "v"} | ^^^^ UP031 -162 | +162 | 163 | "%()s" % {"": "bar"} | = help: Replace with format specifiers @@ -1267,10 +1261,10 @@ UP031_0.py:161:1: UP031 Use format specifiers instead of percent format UP031_0.py:163:1: UP031 Use format specifiers instead of percent format | 161 | "%s" % {"k": "v"} -162 | +162 | 163 | "%()s" % {"": "bar"} | ^^^^^^ UP031 -164 | +164 | 165 | "%(1)s" % {"1": "bar"} | = help: Replace with format specifiers @@ -1278,10 +1272,10 @@ UP031_0.py:163:1: UP031 Use format specifiers instead of percent format UP031_0.py:165:1: UP031 Use format specifiers instead of percent format | 163 | "%()s" % {"": "bar"} -164 | +164 | 165 | "%(1)s" % {"1": "bar"} | ^^^^^^^ UP031 -166 | +166 | 167 | "%(a)s" % {"a": 1, "a": 2} | = help: Replace with format specifiers @@ -1289,10 +1283,10 @@ UP031_0.py:165:1: UP031 Use format specifiers instead of percent format UP031_0.py:167:1: UP031 Use format specifiers instead of percent format | 165 | "%(1)s" % {"1": "bar"} -166 | +166 | 167 | "%(a)s" % {"a": 1, "a": 2} | ^^^^^^^ UP031 -168 | +168 | 169 | "%(1)s" % {1: 2, "1": 2} | = help: Replace with format specifiers @@ -1300,10 +1294,10 @@ UP031_0.py:167:1: UP031 Use format specifiers instead of percent format UP031_0.py:169:1: UP031 Use format specifiers instead of percent format | 167 | "%(a)s" % {"a": 1, "a": 2} -168 | +168 | 169 | "%(1)s" % {1: 2, "1": 2} | ^^^^^^^ UP031 -170 | +170 | 171 | "%(and)s" % {"and": 2} | = help: Replace with format specifiers @@ -1311,7 +1305,7 @@ UP031_0.py:169:1: UP031 Use format specifiers instead of percent format UP031_0.py:171:1: UP031 Use format specifiers instead of percent format | 169 | "%(1)s" % {1: 2, "1": 2} -170 | +170 | 171 | "%(and)s" % {"and": 2} | ^^^^^^^^^ UP031 | From 75ddd04d856f59c852cf72afa5752ef5790b12e7 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Wed, 8 Jan 2025 14:57:32 -0500 Subject: [PATCH 18/18] test: tweak in alignment involving unprintable characters This looks like a bug fix since the caret is now pointing right at the position of the unprintable character. I'm not sure if this is a result of an improvement via the `annotate-snippets` upgrade, or because of more accurate tracking of annotation ranges even after unprintable characters are replaced. I'm tempted to say the former since in theory the offsets were never wrong before because they were codepoint offsets. Regardless, this looks like an improvement. --- ...er__rules__pylint__tests__PLE2512_invalid_characters.py.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2512_invalid_characters.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2512_invalid_characters.py.snap index 1720ccc3aa5b5..d90e38a14cc21 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2512_invalid_characters.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2512_invalid_characters.py.snap @@ -46,7 +46,7 @@ invalid_characters.py:55:25: PLE2512 [*] Invalid unescaped character SUB, use "\ 53 | zwsp_after_multicharacter_grapheme_cluster = f"ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" 54 | 55 | nested_fstrings = f'␈{f'{f'␛'}'}' - | ^ PLE2512 + | ^ PLE2512 56 | 57 | # https://github.com/astral-sh/ruff/issues/7455#issuecomment-1741998106 |